Skip to content

Generates invalid schema. Use allOf when a description is added to a $ref #1808

@nateguchi

Description

@nateguchi

When generating the OpenAPI schema, properties with JSDoc comments that are not simple types will create invalid JSON.

Code:
Image

OpenAPI JSON:

"DogResponse": {
	"properties": {
		"currentMembership": {
			"$ref": "#/components/schemas/MembershipResponse",
			"description": "The current active membership of the dog."
		}
    }
}

$refs cannot have other properties. So the description is overwritten.

If you had several properties sharing the same type, this will cause ambiguity e.g. currentMembership pastMembership

the correct output should be:

"DogResponse": {
	"properties": {
		"currentMembership": {
			"allOf":[
				{
					"$ref": "#/components/schemas/MembershipResponse",
				}
			],			
			"description": "The current active membership of the dog."
		}
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions