1

I am using spring server stub from swagger yaml to generate POJO classes. In my definition, I am having allOf keyword for image property of the Images model. But, the stub generated does not have the correct class reference. It is generating with Object class instead of the type Image class. What is the mistake I am doing here? This is my swagger yaml.

Images:
  title: images
  type: object
  description: A collection of still images related to the work
  properties:
    images:
      type: object
      #items:
      allOf:
          - $ref: '#/components/schemas/Image'
    videos:
      type: array
      items:
        $ref: '#/components/schemas/Video'

This is the generated POJO class of Images

public class Images   {
     @JsonProperty("images")
     private Object images = null;

     @JsonProperty("videos")
     @Valid
     private List<Video> videos = null;

     public Images images(Object images) {
        this.images = images;
        return this;
     }
}

Why is the type Object and not of Image?

Codez
  • 35
  • 7
  • Why do you use `allOf` in the first place? It can be rewritten without `allOf`: `images: {$ref: '#/components/schemas/Image'}` – Helen Jan 18 '20 at 13:21
  • @Helen I know it could be done without allOf here. But, what if this is my requirement. Is there a way this problem can be solved? – Codez Jan 18 '20 at 13:28
  • Looks like a bug. Open an issue at https://github.com/swagger-api/swagger-codegen/issues – Helen Jan 20 '20 at 13:38
  • 1
    Update : I opened an issue. It is fixed now and this is the link https://github.com/swagger-api/swagger-codegen-generators/pull/628 – Codez May 06 '20 at 11:11

0 Answers0