Contributions
Re: Way to Model Response An Array of Different Objects With Identical Properties
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!1.9KViews2likes0CommentsRe: Way to Model Response An Array of Different Objects With Identical Properties
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", ], } } } } } },2KViews0likes5CommentsRe: Way to Model Response An Array of Different Objects With Identical Properties
I know that the schema that I provided describes all three. What development would like is a response that shows explicitly all three. As far as I can tell, this means that the software code should be changed so that the response is three distinct objects and not three identical objects in an array. If there are three distinct objects that are returned - with names like user_project, test_job, and project_info - then these different objects could be displayed in the response. So, this is a coding issue and not a Swagger issue. Do you understand now? The rows_deleted should be an integer. Thanks2.6KViews0likes9CommentsRe: Way to Model Response An Array of Different Objects With Identical Properties
The response from the DELETE operations is as follows: { "changes_made": [ { "rows_deleted": 0, "table_name": "user_project" }, { "rows_deleted": 0, "table_name": "test_job" }, { "rows_deleted": 0, "table_name": "project_info" } ] } I have defined the following response with Swagger Editor: "inline_response_DELETE_Project_200": { "type": "object", "properties": { "changes_made": { "type": "array", "items": { "type": "object", "properties": { "rows_deleted": { "type": "string", "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": "user_project" }, } } } } }, Unfortunately, I cannot define as part of the response the test_job and project_info objects, as part of the array. I cannot save the JSON file when I attempt to do this. Do you understand now?2.6KViews0likes11CommentsRe: Way to Model Response An Array of Different Objects With Identical Properties
What I am trying to do with Swagger Editor is model the response that occurs when a project is deleted. The response is an array of objects, each of which consists of 2 properties - rows_deleted and table_name. When I try to model this array consisting of several identical objects, I get the message duplicated mapping key In other words, I cannot represent the entire response to the delete operation. Or perhaps there is?2.6KViews0likes13CommentsRe: Way to Model Response An Array of Different Objects With Identical Properties
Each one of those objects is unique, even if it does not look so. In order to describe all the data that is returned i.e. information on the number of rows deleted from different tables, in the Swagger Editor, each of the objects would have to have a unique ID of some kind. In the example i provided, the 'ID' is the value of the table_name field. As a result, I cannot model the full response. If each one of those objects were defined as a distinct kind of object in an array, I could model the complete response i.e. precise information on the rows deleted in different tables. Do you see what I mean? I think that this is more of a coding issue than a Swagger issue, and will suggest a coding change to the development team.2.6KViews0likes15CommentsWay to Model Response An Array of Different Objects With Identical Properties
Hi! In Swagger Editor is there a way to model an array of objects each of which has identical properties but with different values for these properties? This array is in a response to a delete operation and has the following structure: { "Modifications_Following_DELETE": [ { "rows_deleted": 0, "table_name": "Table_X" }, { "rows_deleted": 0, "table_name": "Table_XX" }, { "rows_deleted": 0, "table_name": "Table_BBBB" }, { "rows_deleted": 0, "table_name": "Table_CCC" }, { "rows_deleted": 1, "table_name": "Table_DDD" }, { "rows_deleted": 0, "table_name": "Table_EEE" }, { "rows_deleted": 0, "table_name": "Table_FFF" }, { "rows_deleted": 0, "table_name": "Table_HHH" }, { "rows_deleted": 0, "table_name": "Table_III" } ] } It is easy enough to model an array consisting of objects, but getting the names of all the tables is not obvious. Perhaps there is a way? Thanks!Solved3.4KViews0likes17Comments