Membrane API Gateway returns 500 Internal Server Error with the detail Could not parse OpenAPI with title … Check syntax and references. when it cannot validate a request because the OpenAPI document is incomplete. The OpenAPI document in the gateway configuration is to blame, not the request.
The response contains the status 500 Internal Server Error, the title Internal server error., the detail Could not parse OpenAPI with title … Check syntax and references. with the title of your document, the problem type https://membrane-api.io/problems/internal and a link to this page. In development mode, the exception message is included as well. The type internal means that the gateway could not complete the processing of the exchange. In production mode, the title is replaced by Internal Server Error and the details are left out.
An api with openapi specs can validate requests against the document, see OpenAPI configuration and validation. While it validates, Membrane resolves the $ref references of the operation. If a reference points to nothing, the validation cannot continue and Membrane answers with this error in the request flow.
The document uses $ref: '#/components/schemas/…' but has no components section, or components has no schemas.
A property of an application/x-www-form-urlencoded request body refers with $ref to a schema that does not exist under #/components/schemas.
Another place where the validator needs a schema resolves to none. Every $ref must point to an existing entry:
paths:
/products:
post:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
components:
schemas:
Product:
type: object
properties:
name:
type: string
paths:
/products:
post:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
components:
schemas:
Product:
type: object
properties:
name:
type: string
$ref. Every referenced schema must exist under components.schemas.openapi specs are read again.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 ---. The title then reads Internal Server Error, and instead of the details the response only contains a log key. Search the gateway log for this key to find the exception.
Configuration reference:
Tutorials with runnable examples:
Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.