Skip to content

@NotNull not generated when 'required' is declared in inheriting model #7058

@gintautassulskus

Description

@gintautassulskus
Description

Swagger-codegen does not generate the @NotNull annotation for the required property password of model UserRegister. The email property declared in model User is handled correctly, I can see the @NotNull annotation if front the corresponding method.

This has something to do with inheritance. The required field in the inheriting model (in this case - UserRegister) is ignored for both inherited (email) and new (password) properties.

Swagger-codegen version

2.2.3

Swagger declaration file content or url
definitions:
  User:
      type: object     
      required:
        - email
      properties:
        email:
          type: string
  UserRegister:
      allOf:  
        - $ref: '#/definitions/User'
      type: object
      required:
        - password
      properties:
        password:
          type: string
Maven configuration
          <plugin>
               <groupId>io.swagger</groupId>
               <artifactId>swagger-codegen-maven-plugin</artifactId>
               <version>2.2.3</version>
               <executions>
                   <execution>
                       <goals>
                           <goal>generate</goal>
                       </goals>
                       <id>willbot</id>
                       <configuration>
                           <inputSpec>demo.yaml</inputSpec>
                           <language>spring</language>
                           <configOptions>
                               <sourceFolder>src/gen/main/java</sourceFolder>
                               <useBeanValidation>true</useBeanValidation>
                               <enable303>true</enable303>
                           </configOptions>
                           <apiPackage>server</apiPackage>
                           <modelNameSuffix>Dto</modelNameSuffix>
                       </configuration>
                   </execution>
               </executions>
           </plugin>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions