0

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

varun
  • 201
  • 1
  • 5
  • 13
  • 1
    Does this answer your question? [How do I wrap JSON objects?](https://stackoverflow.com/questions/36545405/how-do-i-wrap-json-objects), [Swagger: How to have a property reference a model in OpenAPI 2.0 (i.e. nest the models)?](https://stackoverflow.com/q/26287962/113116) – Helen Apr 14 '20 at 22:22

1 Answers1

2

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"
Nozhan
  • 58
  • 7