-
Notifications
You must be signed in to change notification settings - Fork 210
Closed
Description
Describe the bug
Unable to use an OpenAPI endpoint that has no return type.
To Reproduce
Steps to reproduce the behavior:
- Define a swagger schema that contains a schema-less response,
- Server has a schema-less endpoint that responds with a 204 and application/json as the content type
- Use
createGraphQLSchema
to export a graphql executor with the optionfillEmptyResponses: true
- Execute a query or mutation against endpoint
- Observe that the operation gets executed but that the endpoint returns with an error.
Expected behavior
Either for the operation to return successfully with text or undefined return type OR for createGraphQLSchema
to fail early if responseContentType
is undefined
Screenshots
Server will respond with:
{
"stacktrace": [
"TypeError: Cannot read property 'includes' of undefined",
" at /code/node_modules/dist/openapi-to-graphql/src/resolver_builder.js:472:38",
" at processTicksAndRejections (internal/process/task_queues.js:95:5)"
]
}
If it's swagger schema looks like:
"put": {
"description": "Update a building type",
"operationId": "update_building_type",
"parameters": [
{
"in": "body",
"name": "building_type",
"schema": {
"$ref": "#/definitions/BuildingType"
}
}
],
"responses": {
"204": {
"description": "Success."
},
"401": {
"$ref": "#/responses/UnauthorizedError"
},
"403": {
"$ref": "#/responses/ForbiddenError"
},
"default": {
"$ref": "#/responses/GenericError"
}
},
Additional context
From what I've seen this happens when we call responseContentType.includes
and responseContentType
is undefined. This appears to happen when the source schema does not define a ref or schema.
Metadata
Metadata
Assignees
Labels
No labels