cancel
Showing results for 
Search instead for 
Did you mean: 

Variable with two types or more

Highlighted
New Member

Variable with two types or more

Is there a way that we can use two types or more for a parameter in swagger 2 like when we use oneOf in openAPI 3

1 REPLY 1
Highlighted
Moderator

Re: Variable with two types or more

It depends on the parameter location (in attribute).

 

Path, query, header, and form parameters in OpenAPI 2.0 require a specific type and cannot have multiple types.

 

However, in schemas for body parameters and responses, if you don't specify the type a schema, property, or array items schema, it means "any type" . That's the most you can do in OpenAPI 2.0.

 

definitions:
  MyModel:
    type: object
    properties:
      id:
        type: integer
        example: 1
      data:
        # No "type" means the value can be of any type
        example: 'custom data'

  ArrayOfArbitraryValues:
    type: array
    items: {}
    example: ['string', -1, false]

 

 


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Top Kudoed Authors