swagger-api / swagger-api/swagger-codegen
custom validation message in bean validation annotations
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
[JAVA]
When i try to generate the objects using the below , generate objects does not have message value .
expected:
@JsonProperty("inlineString")
@Nullable
@Size(max=100, message='validation message')
public String getinlineString();
instead getting
@JsonProperty("inlineString")
@Nullable
@Size(max=100)
public String getinlineString();
Test.yaml File
efinitions:
stringPattern:
type: string
minLength: 1
maxLength: 20
pattern: '^([a-zA-Z0-9])*$'
decimalNumber:
type: number
minimum: 0
maximum: 9999999999999.99
multipleOf: 0.01
ApiRequest:
type: object
properties:
stringPattern:
$ref: '#/definitions/stringPattern'
decimalNumber:
$ref: '#/definitions/decimalNumber'
inlineString:
type: string
minLength: 1
maxLength: 20
message :" max number should 20"
Swagger-codegen version
using swagger codegen version 2.4.5
Can you please suggest a way to pull the custom validation message in the yaml file and which in turn generates a object with the same messages.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Test.yaml example and trace how its validation constraints are converted into Java Bean Validation annotations by the Java generation templates. Check the generated ApiRequest output and determine how a custom message should be represented and preserved; done means the generated @Size annotation includes the requested message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100