Skip to content

Commit

Permalink
Fix final warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
david-marconis committed Oct 25, 2024
1 parent aa78c38 commit 1f8b90c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3216,7 +3216,6 @@ protected void setAddProps(Schema schema, IJsonSchemaValidationProperties proper
*/
private CodegenProperty discriminatorFound(String composedSchemaName, Schema sc, String discPropName, Set<String> visitedSchemas) {
Schema refSchema = ModelUtils.getReferencedSchema(openAPI, sc);
ModelUtils.getSimpleRef(sc.get$ref());
String schemaName = Optional.ofNullable(composedSchemaName)
.or(() -> Optional.ofNullable(refSchema.getName()))
.or(() -> Optional.ofNullable(sc.get$ref()).map(ModelUtils::getSimpleRef))
Expand Down Expand Up @@ -3258,7 +3257,9 @@ private CodegenProperty discriminatorFound(String composedSchemaName, Schema sc,
for (Object oneOf : composedSchema.getOneOf()) {
Schema oneOfSchema = (Schema) oneOf;
String modelName = ModelUtils.getSimpleRef((oneOfSchema).get$ref());
CodegenProperty thisCp = discriminatorFound(oneOfSchema.getName(), oneOfSchema, discPropName, visitedSchemas);
// Must use a copied set as the oneOf schemas can point to the same discriminator.
Set<String> visitedSchemasCopy = new TreeSet<>(visitedSchemas);
CodegenProperty thisCp = discriminatorFound(oneOfSchema.getName(), oneOfSchema, discPropName, visitedSchemasCopy);
if (thisCp == null) {
once(LOGGER).warn(
"'{}' defines discriminator '{}', but the referenced OneOf schema '{}' is missing {}",
Expand All @@ -3282,7 +3283,9 @@ private CodegenProperty discriminatorFound(String composedSchemaName, Schema sc,
for (Object anyOf : composedSchema.getAnyOf()) {
Schema anyOfSchema = (Schema) anyOf;
String modelName = ModelUtils.getSimpleRef(anyOfSchema.get$ref());
CodegenProperty thisCp = discriminatorFound(anyOfSchema.getName(), anyOfSchema, discPropName, visitedSchemas);
// Must use a copied set as the anyOf schemas can point to the same discriminator.
Set<String> visitedSchemasCopy = new TreeSet<>(visitedSchemas);
CodegenProperty thisCp = discriminatorFound(anyOfSchema.getName(), anyOfSchema, discPropName, visitedSchemasCopy);
if (thisCp == null) {
once(LOGGER).warn(
"'{}' defines discriminator '{}', but the referenced AnyOf schema '{}' is missing {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ info:
paths:
"/animal":
get:
operationId: animalGet
responses:
'200':
description: OK
Expand Down

0 comments on commit 1f8b90c

Please sign in to comment.