0

In Springfox I once used the following syntax to render a String parameter with a full model (original Github issue):

@PatchMapping(path="/{objId}")
@ApiImplicitParams(@ApiImplicitParam(name="update", dataType="MyClass")) 
    public ApiResponse<MyClass> updateMyClassInst(@PathVariable String objId, @RequestBody String update) {

The reason for this formulation is that if I put MyClass as type for the request body I had no way to distinguish when a property has not been updated or when has been set to null, because both would be deserialized to a null field value.

How do I do that with Springdoc?

watery
  • 5,026
  • 9
  • 52
  • 92

1 Answers1

2

This the equivalent code, using OpenAPI 3.

@PatchMapping(path="/{objId}")
@RequestBody( content = @Content(schema = @Schema(implementation = MyClass.class)))
public ApiResponse<MyClass> updateMyClassInst(@PathVariable String objId, @RequestBody String update) {
    return null;
}

You can have a look at hte migration guide:

And the swagger documentation:

brianbro
  • 4,141
  • 2
  • 24
  • 37
  • Ha! Totally missed the `implementation` property, I did not get it when I read the javadoc. Thanks for the links, I did have checked the migration guide, but not the swagger-core docs which I see give more informations. – watery Jul 11 '20 at 19:15