fastify / fastify/fastify-swagger

JSON Schema Definitions not work

Open
#639 8 comments 5 reactions 0 assignees View on GitHub
bug good first issue
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.