Nico
Nico

Reputation: 21

Customising a Components object - OpenAPI

Is it possible to assign a customised name to a Components object in OpenAPI?

I currently have two Component objects that specify a request schema:

Request1:
type: object
description: Request 1
properties:
  a:
    description: Filter 1 a
    $ref: '#/definitions/Filter1a'
  b:
    description: Filter 1 b.
    $ref: '#/definitions/Filter1b'
 


Request2:
    type: object
    description: Request 2
    properties:
      query:
        type: object
        description: Filter 2.
        properties:
            bool:
              type: object
              properties:
                  must:
                    type: array
                    items:
                      type: object
                      properties:
                        match_all:
                          type: object

In the endpoint description I refer to these schemas as follows:

/v2/myEndpoint: 
    post: 
      tags: 
        - some tags
      operationId: someId
      summary: Some summary
      description: Some description 
      produces:
        - application/json
      parameters: 
        - in: body
          name: body
          required: false
          schema:
            oneOf:
              - $ref: '#/definitions/Request1'
              - $ref: '#/definitions/Request2'

When I publish the yaml file, the UI shows Request1 and Request2 in selection tabs, which carry the names 'Request1' and 'Request2'. Is it possible to assign custom names to them, so that the UI will show the custom names instead? For example 'Custom name request 1' and 'Custom name request 2'?

Many thanks!

Upvotes: 0

Views: 1084

Answers (1)

Maniganda Prakash
Maniganda Prakash

Reputation: 4732

I assume you meant Swagger UI.

title would do that. Link to Open Api Spec.

Request1:
 title: Custom name request 1
 type:...

Request2:
 title: Custom name request 2
 type:...  

Upvotes: 1

Related Questions