2

I have the following controller code:

    public abstract class BaseController<TClientModel extents BaseClientModel> {
       @Operation
       @GetMapping
       Page<TClientModel> get()
    }

    @Data
    public abstract class BaseClientModel {
       int id;
    }

    @RestController
    public class SpecificController extends BaseController<SpecificClientModel> {}

    @Data
    public class SpecificClientModel extends BaseClientModel {
        String name;
    }

Problem: When open-api markup is generated for SpecificController in Swagger, client model in the response is BaseClientModel, not SpecificClientModel and only has id field, and not id+name.

Actual:

{
  "id": 0,
}

Expected:

{
  "id": 0,
  "name": "string",
}

Given I have 40+ specific controllers, is there any way I can make springdoc open-api generate correct markup based on specific generic parameters?

Cortlendt
  • 2,190
  • 4
  • 29
  • 50
  • 1
    It looks like It isn't supported yet. In the official repository there are related issues https://github.com/swagger-api/swagger-core/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+generics – JuanMoreno Feb 05 '20 at 15:31
  • Could you provide a reproducable example on github? Something isn't right in your example. What @Operation and @GetMapping annotations (from which package). extents instead of extends. What is Page object? I don't see it here. `Page get()` it doesn't have a ";" in the end and neither body or abstract word. What is `TClientModel`? I don't see it here I guess it's `SpecificClientModel`? With example it would be way more easy to get some answer – Eugene Kortov Feb 12 '20 at 11:00

1 Answers1

2

The support is now part of v1.2.33 of springdoc-openapi. For example, if you are using spring-mvc, you can declare:

   <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-ui</artifactId>
      <version>1.2.33</version>
   </dependency>
Pang
  • 9,564
  • 146
  • 81
  • 122
brianbro
  • 4,141
  • 2
  • 24
  • 37