-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
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
fqdn=true oneOf invalid refs (global / not relative) #4036
Comments
The problem is the class public void set$ref(String $ref) {
if ($ref != null && !$ref.startsWith("#") && ($ref.indexOf('.') == -1 && $ref.indexOf('/') == -1)) {
$ref = Components.COMPONENTS_SCHEMAS_REF + $ref;
}
this.$ref = $ref;
} If you are using List<Class<?>> oneOfFiltered = Stream.of(oneOf)
.distinct()
.filter(c -> !this.shouldIgnoreClass(c))
.filter(c -> !(c.equals(Void.class)))
.collect(Collectors.toList());
oneOfFiltered.forEach(c -> {
Schema oneOfRef = context.resolve(new AnnotatedType().type(c).jsonViewAnnotation(annotatedType.getJsonViewAnnotation()));
if (oneOfRef != null) {
if (StringUtils.isBlank(oneOfRef.getName())) {
composedSchema.addOneOfItem(oneOfRef);
} else {
composedSchema.addOneOfItem(new Schema().$ref(oneOfRef.getName()));
}
// remove shared properties defined in the parent
if (isSubtype(beanDesc.getClassInfo(), c)) {
removeParentProperties(composedSchema, oneOfRef);
}
}
}); On the other hand, this constant is used for the main model. This is the reason why Schema refSchema = new Schema().$ref(Components.COMPONENTS_SCHEMAS_REF + model.getName()); We have a workaround for Spring Boot (2.7,x). It is possible to define a custom @Configuration
public class OpenApiConfiguration {
...
@Bean
public ModelResolver customModelConverter() {
return new ModelResolver(Json.mapper()) {
@Override
protected String decorateModelName(AnnotatedType type, String originalName) {
String name = super.decorateModelName(type, originalName);
if (!StringUtils.isBlank(originalName)) {
name = name.replaceAll("[.$]", "_");
}
return name;
}
};
}
} |
Thanks for reporting and analyzing this. Should be fixed by #4371 |
when following the example from #3046 (comment)
to having the inheritance / sealed class support work
I noticed that swagger-ui is maxing requests 2 requests
.../api-docs/com.example.Cat
andapi-docs/com.example.Dog
both return 404both of these are cause by using
fqdn=true
andoneOf=[Cat::class, Dog::class]
in the example belowfor whatever reason the generated
$ref's
are "absolute/global" rather than relativethis is strange because "link's / refs" for discriminator.mapping are correct
I am running the latest
org.springdoc:springdoc-openapi-ui:1.5.10
and kotlin packageswith fqdn=true
with fqdn=false
The text was updated successfully, but these errors were encountered: