swagger-api / swagger-api/swagger-codegen
[jaxrs-cxf-cdi] validations not working for the nested referneces in generated code
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I am generating code using swagger-codegen dependency version 2.3.1. The swagger file is having nested reference as shown below:
Pet:
title: Pet object
properties:
id:
type: string
example: 01234567-0123-0123-0123-01234567892453
info:
$ref: '#/definitions/info'
info:
title: Type object.
properties:
owner:
type: string
example: John
maxLength: 40
Generated code snipper for Pet model:
@ApiModelProperty(value = "")
@JsonProperty("info")
public InfoDTO getInfo() {
return info;
}
public void setInfo(InfoDTO info) {
this.info = info;
}
Generated code snippet for info model:
@ApiModelProperty(example = "owner", value = "")
@JsonProperty("owner")
@Size(max=40) public String getOwner() {
return owner;
}
Even though the generated code is having the @Size annotation, when invoking the API, the request parameter is not getting validated.
Am I missing anything here? Appreciate any help to validate the conditions mentioned in the references.
Swagger-codegen version
2.3.1
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 by reproducing the request validation behavior with the generated Pet and InfoDTO models in the JAX-RS-CXF-CDI setup, focusing on the nested info.owner constraint. Trace the generated validation path and confirm whether a request whose owner exceeds the shown maxLength is rejected; done means nested-reference constraints are enforced during API invocation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100