How to hide swagger ref attributes in specific paths?

Viewed 147

I have this structure in swagger documentation:

  FunctionTitle:
    type: object
    required:
    - funcId
    - czechName
    - priority
    properties:
      funcId:
        type: number
        format: id
        example: 1226
      czechName:
        type: string
        example: Guvernér
      priority:
        type: number
        example: 21
      org:
        $ref: '#/definitions/Organ'
      funcType:
        $ref: '#/definitions/FunctionType' 

In some path I want to return this structure, but without properties org and funcType. So my response should be something like that:

{
"funcId" : 1226,
"czechName" : "Guvernér",
priority: 21
}

I didnt find how to choose not to return properties org and funcType. I know I can create another model for it, but it will be better for me to only hide properties as I want and not to create another model. Here is example of my path:

  /periods:
    get:
      tags:
      - developers & users
      summary: Periods
      operationId: periods
      description: |
        By passing in the appropriate options, you can search for
        available inventory in the system
      produces:
      - application/json
      responses:
        200:
          description: search  matching criteria
          schema:
            type: object
            properties:
              periods:
                type: array
                items:
                  $ref: '#/definitions/FunctionTitle'
        400:
          description: bad input parameter

Thank you for your answers!

0 Answers
Related