-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
The generator ran into a loop when a composite schema recursively added itself. This change provides a reproducing example and fixes the issue by extending DefaultCodegen#addProperties() by an additional circuit breaker parameter. When additionalProperties() is called with a schema instance for which the properties have already been added, the method directly returns and does not run into the loop.
- Loading branch information
Karsten Thoms
authored
Mar 1, 2022
1 parent
21f649e
commit 6a7fc38
Showing
4 changed files
with
105 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
modules/openapi-generator/src/test/resources/bugs/recursion-bug-4650.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: Test | ||
version: v1 | ||
paths: | ||
/api/v1/filters: | ||
get: | ||
responses: | ||
'200': | ||
description: default response | ||
content: | ||
'*/*': | ||
schema: | ||
$ref: '#/components/schemas/Filter' | ||
components: | ||
schemas: | ||
AndFilter: | ||
type: object | ||
allOf: | ||
- $ref: '#/components/schemas/Filter' | ||
- type: object | ||
properties: | ||
operator: | ||
type: string | ||
default: and | ||
enum: | ||
- and | ||
- or | ||
filters: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/Filter' | ||
Filter: | ||
type: object | ||
properties: | ||
operator: | ||
type: string | ||
enum: | ||
- and | ||
- or | ||
example: | ||
operator: eq | ||
field: name | ||
value: john | ||
discriminator: | ||
propertyName: operator | ||
mapping: | ||
and: '#/components/schemas/AndFilter' | ||
or: '#/components/schemas/OrFilter' | ||
oneOf: | ||
- $ref: '#/components/schemas/AndFilter' | ||
- $ref: '#/components/schemas/OrFilter' | ||
OrFilter: | ||
type: object | ||
allOf: | ||
- $ref: '#/components/schemas/Filter' | ||
- type: object | ||
properties: | ||
operator: | ||
type: string | ||
default: or | ||
enum: | ||
- and | ||
- or |