How to wrap root tag to existing endpoint in swagger

We have an endpoint with json response as in Code1. There is an user condition and when this is met second version of json with string “Employee” added as in Code2.

I’m trying to document this in swagger and having issues embedding these schema’s. Below is my code, but some how getting swagger invalid with “paths must not include query string” and “potentially unused component has been detected errors” and so on. I’m not sure if this is right way of doing it or if there is any better way to achieve this? Any help would be really helpful


Below is my existing json response in for one of the end point as in Code1:.

    Code1:
    [
       {
          "EmpId":{
             "String":"ABCD",
             "Valid":true
          },
          "Department":{
             "Float64":0,
             "Valid":true
          }
       }
    ]

We have an optional parameter where the condition is met, below will be the response
    Code2:

    {
       "Employee":[
          {
             "EmpId":{
                "String":"ABCD",
                "Valid":true
             },
             "Department":{
                "Float64":0,
                "Valid":true
             }
          }
       ]
    }

Below is my model to achieve this and we have an if condition within the code to determine which response to get.

    type Employeewithroot struct {
        Employees []Employees `json:"Employee"`
    }
    type Employees struct {
        EmpNbr     sql.NullString  `json:"EmpNbr"`
        DateofJoin      sql.NullString   `json:"DateofJoin"`
        DeptId  sql.NullString  `json:"DeptId"`
        DeptName sql.NullString  `json:"DeptName"`
    }


    openapi: 3.0.1
    info:
      title: API's
      description: >-
        REST API's for abc
      contact:
        name: ABC
        email: ABC
      version: "1.0.0"
    servers:
      - url: "http://localhost:8080/"
    tags:
      - name: Employees     
        description: Get Employees info 
    paths:
      /Employees:
        get:
          description: Get Employee info 
          summary: Get Employee.
          tags:
          - Employees
          security:
          - basicAuth:
            - '[]'
          operationId: GetEmployees
          parameters:
          - name: EmpNbr
            in: query
            description: Employee ID(Example:0123456789)
            required: true
            schema:
              type: string
          - name: DateofJoin
            in: query
            description: Input DateofJoin(Example:mmddyyyy(01012023))
            required: true
            schema:
              type: string
          responses:
            '200':
              description: OK.
              content:
                application/json:
                  schema:
                    type: array
                    items:
                      $ref: '#/components/schemas/Employees'
      /Employees?EmpNbr={EmpNbr}&DateofJoin={DateofJoin}&cond={cond}:
        get:
          description: Get Employees info as per additional condition 
          summary: Get EmployeeRoot Hdr.
          tags:
          - Employees
          operationId: GetEmployeeRootHdr
          parameters:
          - name: EmpNbr
            in: path
            description: Emp ID(Example:0123456789)
            required: true
            schema:
              type: string
          - name: DateofJoin
            in: path
            description: Input DateofJoin(Example:mmddyyyy(01012023))
            required: true
            schema:
              type: string
          - name: cond
            in: path
            description: additional check
            required: true
            schema:
              type: string
            allowEmptyValue: true      
          responses:
            '200':
              description: OK.
              content:
                application/json:
                  schema:
                    type: array
                    items:
                      $ref: '#/components/schemas/Employeewithroot'
    components:
      schemas:
        Employeewithroot:
          properties:
            Employee:
              items:
                $ref: '#/components/schemas/Employees'
              type: array
              x-go-name: Employees
        Employees:
          properties:
            EmpNbr:
              $ref: '#/components/schemas/NullString'
            DateofJoin:
              $ref: '#/components/schemas/NullString'
            DeptId:
              $ref: '#/components/schemas/NullString'
            DeptName:
              $ref: '#/components/schemas/NullString'
            x-go-package: pkg/model
      securitySchemes:
        basicAuth:
          type: apiKey
          name: Authorization
          in: header    

Added the steps to the question

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật