简体   繁体   中英

YAML Multiple response for single status code

Help me with multiple response body with single status code in yaml format.

Ex::

'401':
  description: Not Found
  headers:
    Content-Type :
      type: string
      default: application/json;charset=UTF-8
  examples:
    errorCode: '48'
    errorLabel: RONotAllowed
    errorDescription: Unable to execute the remote operation as it is not allowed for the vehicle
'401':
  description: Not Found
  headers:
    Content-Type :
      type: string
      default: application/json;charset=UTF-8
  examples:
    errorCode: '45'
    errorLabel: VehicleNotFound
    errorDescription: Vehicle could not be found using VIN provided  in request
'401':
  description: Not Found
  headers:
    Content-Type :
      type: string
      default: application/json;charset=UTF-8
  examples:
    errorCode: '49'
    errorLabel: VehicleAlreadyOnline
    errorDescription: Unable to execute the remote operation since   vehicle is already online

Using above code i found error ✖ YAML Syntax Error Duplicated mapping key at line 608, column 9: '401'

If I understand this correctly you are trying to provide a list of examples for the error code. For this you need:

'401':
  description: Not Found
  headers:
    Content-Type :
      type: string
      default: application/json;charset=UTF-8
  examples:
    - errorCode: '48'
      errorLabel: RONotAllowed
      errorDescription: 'Unable to execute the remote operation as it is not allowed for the vehicle'
    - errorCode: '45'
      errorLabel: VehicleNotFound
      errorDescription: 'Vehicle could not be found using VIN provided  in request'
    - errorCode: '49'
      errorLabel: VehicleAlreadyOnline
      errorDescription: 'Unable to execute the remote operation since   vehicle is already online'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM