Skip to content

Instantly share code, notes, and snippets.

@quezak
Created May 17, 2019 09:39
Show Gist options
  • Save quezak/d39343604498153c665b35d19a53e836 to your computer and use it in GitHub Desktop.
Save quezak/d39343604498153c665b35d19a53e836 to your computer and use it in GitHub Desktop.
openapi generator schema example with different return types for different codes
{
"swagger": "2.0",
"host": "test.test",
"schemes": ["https"],
"info": { "version": "1.0", "title": "Test" },
"paths": {
"/test": {
"get": {
"summary": "Test",
"description": "Test",
"operationId": "test",
"produces": ["application/json"],
"parameters": [],
"responses": {
"200": {
"description": "Successful operation",
"schema": { "$ref": "#/definitions/TestResponse" }
},
"default": {
"description": "Unexpected error",
"schema": { "$ref": "#/definitions/ErrorResponse" }
}
}
}
}
},
"definitions": {
"TestResponse": {
"type": "object",
"properties": {
"testField": { "type": "integer" }
}
},
"ErrorResponse": {
"type": "object",
"properties": {
"errorMessage": { "type": "string" }
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment