Skip to content

[codegen][JAVA] BUG: Ref of a single type ignores min/max and pattern during model generation #8001

@FatCash

Description

@FatCash
Description

If you add a single typed string "object" to pet definition in petstore like below.

The generator does not create any @SiZe annotation and no @pattern.

But when you paste content of nickName instead of $ref, it does create the annotations.
This has to be a bug or am I missing something?

I need to reuse this nickName type in various places and would like to have the min/max constraints defined only once. How do I achieve this?

Note if you create type: object with only one string property then it generates correctly. But it is not appealing to have an objet just for hosting one string.

Swagger-codegen version

2.3.1

Addition to petstore.yml
      nick:
        $ref: "#/definitions/nickName"
  nickName:
    type: string
    minLength: 1
    maxLength: 3
    pattern: "^[A-Z]+$"
Command line used for generation

swagger-codegen generate -i ./petstore.yml -l spring -o ./petstore

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions