-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
When using io.swagger.v3.core.filter.SpecFilter.removeBrokenReferenceDefinitions on the provided OpenAPI 3.1.0 specification, the function is incorrectly removing the RequestDto schema definition from the components.schemas section. The schema is still referenced in the webhook newPet request body, but the actual schema definition is removed from the OpenAPI spec, resulting in a broken reference.
Input OpenAPI Spec:
The original OpenAPI specification includes a schema definition RequestDto under the components.schemas, which is referenced by the newPet webhook's request body schema.
openapi: 3.1.0
info:
title: OpenAPI definition
version: v0
servers:
- url: http://localhost
description: Generated server url
paths: {}
components:
schemas:
RequestDto:
properties:
personalNumber:
type: string
webhooks:
newPet:
post:
requestBody:
description: Information about a new pet in the system
content:
application/json:
schema:
$ref: '#/components/schemas/RequestDto'
description: Webhook Pet
responses:
'200':
description: >-
Return a 200 status to indicate that the data was received
successfullyGenerated OpenAPI Spec:
After using the removeBrokenReferenceDefinitions method, the resulting OpenAPI spec incorrectly removes the RequestDto schema from the components.schemas section, even though it is still referenced. This causes a broken reference in the generated spec:
openapi: 3.1.0
info:
title: OpenAPI definition
version: v0
servers:
- url: http://localhost
description: Generated server url
paths: {}
components:
schemas: {}
webhooks:
newPet:
post:
requestBody:
description: Information about a new pet in the system
content:
application/json:
schema:
$ref: '#/components/schemas/RequestDto'
description: Webhook Pet
responses:
'200':
description: >-
Return a 200 status to indicate that the data was received
successfullyExpected Result
The SpecFilter.removeBrokenReferenceDefinitions method should retain schema definitions that are referenced in other parts of the OpenAPI specification (such as in webhooks, request bodies, or responses). In this case, since the RequestDto schema is being referenced in the newPet webhook, the method should not remove the RequestDto schema from the components.schemas section.
The expected behavior is as follows:
The RequestDto schema should remain in the components.schemas section, as it is actively referenced in the webhook newPet.