Missing $ref for BadRequestHttpException
#1098
Unanswered
apasquini95
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone, I have a question about
$refwhen handling exceptions such asBadRequestHttpException. I have a controller like this one:As you can see both of the two handlers can throw a
NotFoundHttpExceptionor aBadRequestHttpException. Scramble is capable to create the corresponding exception's schemas, but while theNotFoundHttpExceptionis linked by$ref, theBadRequestHttpException's schema is repeated twice.{ "openapi": "3.1.0", "info": { "title": "Laravel", "version": "0.0.1" }, "servers": [ { "url": "http://localhost/api" } ], "paths": { "/endpoint-1": { "get": { "operationId": "endpoint-1", "summary": "Summary of myHandler", "tags": [ "My" ], "parameters": [ { "name": "test_param", "in": "query", "schema": { "type": "boolean", "default": false } } ], "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "type": "integer", "const": 1 } } } }, "400": { // First schema "description": "Bad request", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "Error overview." } }, "required": [ "message" ] } } } }, "404": { // Using $ref as wanted "$ref": "#/components/responses/NotFoundHttpException" } } } }, "/endpoint-2": { "get": { "operationId": "endpoint-2", "summary": "Summary of myOtherHandler", "tags": [ "My" ], "parameters": [ { "name": "test_param", "in": "query", "schema": { "type": "boolean", "default": false } } ], "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "type": "integer", "const": 2 } } } }, "400": { // Second schema "description": "Bad request", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "Error overview." } }, "required": [ "message" ] } } } }, "404": { // Using $ref as wanted "$ref": "#/components/responses/NotFoundHttpException" } } } } }, "components": { "responses": { "NotFoundHttpException": { "description": "Not found", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "description": "Error overview." } }, "required": [ "message" ] } } } } // Missing schema declaration for BadRequestHttpException } } }Is it an intended behaviour or am I missing something?
For this purpose, I created a branch on this public repository.
Beta Was this translation helpful? Give feedback.
All reactions