Forum Discussion

dunkc's avatar
dunkc
Occasional Contributor
8 years ago
Solved

Can I mix parameter types in a Swagger document

I've an API definition (https://app.swaggerhub.com/api/dunkc/Payment/1.0) which has a single path to post the resource defined in the message body but also allows a query parameter to be passed. This...
  • RonRatovsky's avatar
    RonRatovsky
    8 years ago

    Hi there, glad to see you've solved the issue.

     

    There are two places parameters can be declared inside an API spec.

    The first is at the top level, being referred to as the Parameters Definitions Object - http://swagger.io/specification/#parameters-definitions-object-103. There, you can define parameters that can be reused in your spec. For that reason, the structure is a map of names that you give to those parameters, and their actual structure.

     

    The second place is under the operations themselves. In that case, `parameters` is an array of parameters, that can either be defined directly there or referenced to the parameters defined above for reuse.

     

    The structure of `parameters` differs (object vs array), which is why you saw a different example than what you actually needed.