I've API Spec specified in OAS 3.0
post:
tags:
- One Time Payment
summary: One Time Payment API
operationId: oneTimePaymentUsingPOST
parameters:
- in: body
name: realTimePaymentRequest
description: realTimePaymentRequest
required: true
schema:
$ref: '#/components/schemas/RealTimePaymentRequest'
When I edit this spec file in https://editor.swagger.io/ - It's throwing errors as :
Structural error at paths./banks/payments.post.parameters.0.in
should be equal to one of the allowed values
allowedValues: path, query, header, cookie
I can see that describing in: body in parameters is supported as per https://swagger.io/docs/specification/2-0/describing-request-body/
thought Swagger Editor is throwing errors. What could be wrong here ? schema ?
Any help is appreciated. Thank you.
Format. An OpenAPI document that conforms to the OpenAPI Specification is itself a JSON object, which may be represented either in JSON or YAML format.
In OpenAPI 3.0, parameters are defined in the parameters section of an operation or path. To describe a parameter, you specify its name , location ( in ), data type (defined by either schema or content ) and other attributes, such as description or required . Here is an example: paths: /users/{userId}:
OpenAPI 3 is the successor of the widely used OpenAPI/Swagger 2.0 format, for machine-readable API definitions. It contains a variety of changes, and even though everything that can be expressed in Version 2 is supported in Version 3 as well, specifications are not backwards-compatible.
The most you can do is define these parameters in the global parameters section (in OpenAPI 2.0) or the components/parameters section (in OpenAPI 3.0) and then $ref all parameters explicitly in each operation. The drawback is that you need to duplicate the $ref s in each operation.
In OpenAPI 3.0, in: body
and in: formData
parameters were replaced with requestBody
:
post:
tags:
- One Time Payment
summary: One Time Payment API
operationId: oneTimePaymentUsingPOST
requestBody:
description: realTimePaymentRequest
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RealTimePaymentRequest'
The documentation link you posted is for OpenAPI 2.0. For OpenAPI 3.0, use this link:
https://swagger.io/docs/specification/describing-request-body/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With