fastify / fastify/fastify-swagger
JSON Schema Definitions not work
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 219
- Avg merge
- 4h 24m
- Merged PRs (30d)
- 2
Description
### Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the issue has not already been raised
` "@fastify/swagger": "7.4.1",`
### Issue
Hi Guys, I add new schema with addSchema in my fastify like this :
```
{
$id: 'http://foo/common.json',
type: 'object',
definitions: {
foo: {
$id: '#address',
type: 'object',
properties: {
city: { type: 'string' }
}
}
}
}
```
and used in my route schema
```
schema: {
body: {
$ref: 'http://foo/common.json#/definitions/foo'
}
},
```
its work in fastify no error found, but error in swagger
Could not resolve reference: Could not resolve pointer: /definitions/def-0/definitions/foo ddoes not exist in document
and when i check /documentation/json there is no my definitions inside -> definitions -> def-0
and models only {}
Contributor guide
Research direction
Start with the addSchema usage and the route schema shown in the issue, then inspect the generated /documentation/json output and the unresolved reference. Compare the reported definitions structure with the linked pull request #676; done means the schema reference resolves and the generated documentation includes the expected model definitions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100