1

I am autogenerating my models using Swagger autogen tool. I am trying to create a generic type for a member variable. In the example below I am trying to create a generic value generiValuefor my employee class.

public class Employee<T> implements Comparable<Employee<T>> {
    @NotEmpty
    Long id;
    @NotBlank
    String employeeName;
    @NotNull
    T genericValue;

}

This is my swagger.yaml:

Employee:
  type: object
    properties:
      id:
        type: "integer"
        format: "int64"
      employeeName:
        type: "string"
        format: "string"        
      genericValue:
        type: generic

Is it possible to create a generic variable or is it not supported in swagger autogeneration?

I tried to do using AnyValue

components:
  schemas:
    AnyValue: {} 

but the code is not generated for Java in Generic form.

Note that I am using OpenAPI version 3.0.0.

Ayman Arif
  • 1,456
  • 3
  • 16
  • 40

0 Answers0