Comments (2)
Hi,
I had a look and the error is from fastify, not fastify-openapi-glue.
Putting in a console.log(JSON.stringify(item,null,2));
in just before fastify route registration in generatedProject/node-modules/fastify-openapi-glue/index.js shows the config passed to fastify.
{
"method": "POST",
"url": "/MyPath",
"schema": {
"summary": "My Test Path",
"response": {
"200": {
"allOf": [
{
"allOf": [
{
"type": "object",
"x-abstract": true,
"properties": {
"Identifier": {
"type": "string",
"description": "Identifier of response",
"minLength": 1
}
}
}
]
},
{
"type": "object",
"required": [
"myPayload"
],
"properties": {
"myPayload": {
"type": "string"
}
}
}
]
}
}
},
"operationId": "MyPath",
"openapiSource": {
"summary": "My Test Path",
"responses": {
"200": {
"description": "Success",
"x-nullable": false,
"schema": {
"allOf": [
{
"allOf": [
{
"type": "object",
"x-abstract": true,
"properties": {
"Identifier": {
"type": "string",
"description": "Identifier of response",
"minLength": 1
}
}
}
]
},
{
"type": "object",
"required": [
"myPayload"
],
"properties": {
"myPayload": {
"type": "string"
}
}
}
]
}
}
}
}
}
The openapiSource property is ignored by fastify.
This config can easily be fed to a very simple fastify server, e.g. see:
test-fastify.js.txt
As far as I can see the schema is valid JSON schema, but somehow fastify doesn't correctly process it. One thing that might be missing is a body parameter, it could be that fastify requires an input parameter on a POST operation. I checked by changing the method to GET but still got the same schema error :-(
Looking at a minimal doc that satisfies your schema
{
"myPayload": "ABCDEFGH",
"Identifier": "ABCDEFGHIJKLMNOPQRSTU"
}
it might be an option to simplify your schema, although I suspect that your original schema is bigger than this.
I'm out of ideas for now, and I would suggest taking the simple fastify server code attached to the fastify project for feedback.
Kind regards,
Hans
from fastify-openapi-glue.
Thanks for the fast reply. You point me in the right direction.
If I add type: object
to the schema node in my yaml it works.
responses:
'200':
description: Success
x-nullable: false
schema:
type: object
allOf:
- $ref: '#/definitions/MyResponse'
- type: object
required:
- myPayload
properties:
myPayload:
type: string
from fastify-openapi-glue.
Related Issues (20)
- example fails with FST_ERR_SCH_VALIDATION_BUILD HOT 3
- Validation Errors when embedding $refs to models that contain "x-" or "example" keywords HOT 3
- Error in Response Validation Message HOT 9
- Middleware HOT 3
- [email protected] deprecation notice (FSTDEP012) "Request#context will be removed in `fastify@5` HOT 4
- No validation error when non `application/json` response provided by API HOT 2
- Return route options from operationResolver HOT 2
- [Discussion] [Request] Rename `service` => `handlers` in options HOT 4
- Suggestion about the TS imports errors HOT 7
- using "example" in swagger api HOT 7
- PARAMETERS method is not supported: when using cross-method parameters HOT 3
- Schema validation HOT 2
- Presence of cookie not being validated HOT 5
- and connected security requirements not possible. HOT 7
- Multiple Security Handlers Error Handling HOT 4
- "Error: 'specification' parameter must contain a valid version" when trying to reference schema from another file HOT 6
- FEATURE REQUEST: Mark some routes as unrouted/static (no operationId logic) HOT 3
- References getting stripped from response HOT 2
- TypeScript template for fastify-openapi-glue cli? HOT 2
- `opts` ignored in default template? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastify-openapi-glue.