0

We have a Spring Boot service with a class that has ManyToOne relationships to other models. These show as links in responses, but to set them in a POST, PUT, or PATCH you send in a URI for that field.

@ManyToOne(fetch = FetchType.EAGER)
@Schema(description = "This is a test", example = "https://uri/id --in links section on GET", type = "java.net.URI")
    private OtherEntity otherEntity;

In the Springdoc generated swagger documentation, it's just showing as:

otherEntity string

When we were using Springfox to generate the Swagger, using APIModelProperty, it would show string($URI) with the example and everything intact.

@ApiModelProperty(example = "https://uri/id --in links section on GET", dataType = "java.net.URI")
private OtherEntity otherEntity


string($uri)
example: https://uri/id --in links section on GET
https://<base>/api/v1/otherEntities/$(otherEntityId)

We are using RepresentationModelAssemblerSupport to instantiate EntityModels to include the links section and selflinks. Not sure if I need to add something around that to get this to work. We'd like to keep it autogenerating and not resort to writing our own definitions.

I am currently looking at using SpringDocUtils.getConfig().replaceWithSchema to potentially globally set the schema for certain types, but I thought I'd post here while I'm fiddling with that option.

Thanks!

Ram
  • 1
  • 2

0 Answers0