Can you use enum with example? I have tried without success.
Here is the code:
"inline_response_DELETE_Project_200": { "type": "object", "properties": { "changes_made": { "type": "array", "items": { "type": "object", "properties": { "rows_deleted": { "type": "integer", "description": "The number of rows deleted when the project was deleted.", "example": 0 }, "table_name": { "type": "string", "description": "The name of the table where the row was deleted.", "example": , "enum": [ "user_project", "test_job", "project_info", ], } } } } } },
Okay, that will not produce what you want. Please read https://swagger.io/docs/specification/adding-examples/ for a deeper explanation on how to add examples to responses. It should give you enough information on the right steps. If you run into any issues, please share the definitiion you got to and we'll take it from there.
As a side note - the Editor is intended to be used with YAML and not JSON. By using JSON, you will not get some of the benefits of the editor. Converting to YAML would be as simple as copying the JSON and pasting it again into the Editor. It will automatically detect it and ask if you want to convert it to YAML.
By reading the pages that you cited and by using YAML, I was able to document the response that consisted of a multi-item example. Thanks for your help!
Awesome! Happy to hear.
@BostonKevin could you share a code snippet?
I'm struggling with the same issue.
I cannot give you the exact details, but a successful response iwith a multi-item response in YAML could be defined as:
inline_response_DELETE_200: type: object properties: changes_made: type: array items: type: object properties: rows_deleted: type: integer description: The number of rows deleted. table_name: type: string description: The table where a row was deleted. example: - rows_deleted: 1 table_name: user_project - rows_deleted: 0 table_name: test_job - rows_deleted: 1 table_name: project_info
The above schema could be invoked in the description of the DELETE resource, as follows:
responses: '200': description: Success content: application/json: schema: $ref: '#/components/schemas/inline_response_DELETE_200'
Hope this helps!
Subject | Author | Latest Post |
---|---|---|