Membrane API Gateway returns 500 Internal Server Error when response validation is on, but the OpenAPI document cannot be used to validate the backend response. Parts of the document that its references point to are missing. The cause is the OpenAPI document in the gateway configuration, not the client or the backend.
The response contains the status 500 Internal Server Error, the title Internal server error., the detail Could not parse OpenAPI with title Fruit Shop API. Check syntax and references. with the title of the document, the problem type https://membrane-api.io/problems/internal and a link to this page. The type internal means that the gateway could not process the message. In production mode, the title is Internal Server Error and the detail is replaced by a log key.
With validateResponses on, the OpenAPI validator checks every backend response against the response definitions of the operation in the OpenAPI document. To do that, it resolves the schemas the definitions refer to. If a referenced part is missing, the response cannot be validated, and the client receives this error instead of the backend response.
A response definition refers to #/components/schemas/Product, but the document has no components section, no schemas section, or no schema with that name:
paths:
/products:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
paths:
/products:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
The reference contains a typo, uses the wrong case, or points to a schema that was renamed or removed. The validator then has no schema to validate against.
$ref points to an existing entry under components/schemas. A linter or editor with OpenAPI support finds broken references quickly.As a temporary workaround, switch off response validation for the document:
api:
port: 2000
openapi:
- location: fruitshop-api.yml
validateResponses: false
api:
port: 2000
openapi:
- location: fruitshop-api.yml
validateResponses: false
By default, Membrane runs in development mode and adds details to error responses that help you find the problem. These details may reveal information about your setup. In production, turn them off:
configuration:
production: trueconfiguration: production: true
Add the configuration document to your apis.yaml and separate it from the APIs with ---.
Configuration reference:
Tutorials with runnable examples:
Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.