Search code examples
swagger-2.0swagger-editor

Swagger documentation: How to update the content of the body


I am new to API swagger documentation so looking your support. I am on the way to generate the curl. In the swagger editor i have written below code in the definition section

definitions: 
  Instrument_users:
    type: "object"
    required:
    - "proposal_id" 
    - "user_id" 
    - "data_access_role"
    properties:
      proposal_id:
        type: "integer"
        example: "244"
      user_id:
        type: "integer"
        example: "1010"        
      data_access_role:
        type: "integer"
        example: "2"    
        default: "2"
    xml:
      name: "Instrument_users"    

which generates body as mentioned below in the right section of the editor

{
  "proposal_id": "244",
  "user_id": "1010",
  "data_access_role": "2"
}

What code do I need to write to expect below body content in the right section of the swagger

{ "proposal_user":
{
  "proposal_id": "244",
  "user_id": "1010",
  "data_access_role": "2"
}}

Thanks


Solution

  • you should write this:

    definitions:
      Instrument_users:
        type: "object"
        properties:
          proposal_user:
            type: "object"
            properties:
              proposal_id:
                type: "string"
                example: "244"
              user_id:
                type: "string"
                example: "1010"
              data_access_role:
                type: "string"
                example: "2"