oapi-codegen
oapi-codegen copied to clipboard
Splitted specification leads to unresolved references
I have created a project to illustrate the problem: https://github.com/tmartin-git/oapi-codegen-unresolvedrefs
In short, if you have a splitted specification (components in a seperate yaml file) and have a schema that references another schema, then this second one does not appear in the generated spec embedded inside the go code (base64 gzip encoded).
Here is a specification excerpt (components is defined in a seperate file):
components:
schemas:
Pet:
allOf:
- $ref: '#/components/schemas/NewPet'
- required:
- id
properties:
id:
type: integer
format: int64
description: Unique id of the pet
PetExtra:
$ref: '#/components/schemas/PetExtra'
PetExtra:
type: string
description: PetExtra description
<truncated>
`
This leads to a failure when validation occurs and you get this kind of error message :
`msg="failed to resolve \"configuration_api\" in fragment in URI: \"#/components/schemas/configuration_api\": map key \"configuration_api\" not found`