We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Imagine some schemas in components like these where I whittle it down to only enough properties to demonstrate the problem:
Pageable: type: object properties: sort: $ref: '#/components/schemas/Sort' title: Pageable Sort: type: object properties: sorted: type: boolean title: Sort Page_Foo_: type: object properties: pageable: $ref: '#/components/schemas/Pageable' sort: $ref: '#/components/schemas/Sort'
This causes an NPE because the sort property $ref is not expanded, because #/components/schemas/Sort was seen when expanding Pageable.
The text was updated successfully, but these errors were encountered:
Here is a diff that should fix the problem:
diff --git a/src/main/java/io/redskap/swagger/brake/core/model/transformer/SchemaTransformer.java b/src/main/java/io/redskap/swagger/brake/core/model/transformer/SchemaTransformer.java index eeb1524..2fa60cd 100644 --- a/src/main/java/io/redskap/swagger/brake/core/model/transformer/SchemaTransformer.java +++ b/src/main/java/io/redskap/swagger/brake/core/model/transformer/SchemaTransformer.java @@ -46,7 +46,9 @@ public class SchemaTransformer implements Transformer<io.swagger.v3.oas.models.m if (isNotBlank(ref) && SeenRefHolder.isNotSeen(ref)) { io.swagger.v3.oas.models.media.Schema resolvedSchema = getSchemaForRef(ref); SeenRefHolder.store(ref); - return internalTransform(resolvedSchema); + Schema schema = internalTransform(resolvedSchema); + SeenRefHolder.remove(ref); + return schema; } Schema.Builder schemaBuilder = new Schema.Builder(swSchema.getType()); @@ -112,6 +114,10 @@ public class SchemaTransformer implements Transformer<io.swagger.v3.oas.models.m get().add(refName); } + static void remove(String refName) { + get().remove(refName); + } + static void clear() { HOLDER.remove(); }
Sorry, something went wrong.
#15 Fix for recursive schemas when a is already seen
edaf665
Fixed.
No branches or pull requests
Imagine some schemas in components like these where I whittle it down to only enough properties to demonstrate the problem:
This causes an NPE because the sort property $ref is not expanded, because #/components/schemas/Sort was seen when expanding Pageable.
The text was updated successfully, but these errors were encountered: