Closed
Description
Description of the Bug Report
When generating an OpenApi schema using python manage.py generateschema --file schema.yml
, the schema is generated without errors, but references non-existent fields via $ref
, making it unuseable.
E.g.:
paths:
/login:
post:
operationId: create/login
description: ''
parameters: []
tags:
- login
requestBody:
content:
application/vnd.api+json:
schema:
required:
- data
properties:
data:
type: object
required:
- type
additionalProperties: false
properties:
type:
$ref: '#/components/schemas/type' # <--- This does not exist
id:
$ref: '#/components/schemas/id' # <--- This does not exist
links:
type: object
properties:
self:
$ref: '#/components/schemas/link' # <--- This does not exist
attributes:
type: object
properties: {}
For reference, this is what #/components
looks like in the generated file:
components:
schemas:
Login:
type: object
required:
- type
- id
additionalProperties: false
properties:
type:
$ref: '#/components/schemas/type' # <--- This does not exist
id:
$ref: '#/components/schemas/id' # <--- This does not exist
links:
type: object
properties:
self:
$ref: '#/components/schemas/link' # <--- This does not exist
attributes:
type: object
properties:
expiry:
type: string
readOnly: true
token:
type: string
readOnly: true
SuccessMessage:
type: object
required:
- type
- id
additionalProperties: false
properties:
type:
$ref: '#/components/schemas/type' # <--- This does not exist
id:
$ref: '#/components/schemas/id' # <--- This does not exist
links:
type: object
properties:
self:
$ref: '#/components/schemas/link' # <--- This does not exist
attributes:
type: object
properties:
success:
type: boolean
readOnly: true
Checklist
- Certain that this is a bug (if unsure or you have a question use discussions instead)
- Code snippet or unit test added to reproduce bug