swagger-api / swagger-api/swagger-codegen
[JAVA] Correct field validation in list of elements
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I have generated class:
@Validated
public class SomeClass extends AnotherSomeClass implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("...")
@Valid
private List<Element> elements = null;
...
}
It uses as a request body for POST controller. When it try to send request to controller without one required field from Element class, I have an error like: "elements[0].someField doesnt exist". Could I validate entity instead of list of entities with swagger codegen? I want to have error like: "someField doesnt exist" without list name and index of the element. Could you provide code example for this?
Swagger-codegen version
0.19.0.2
Command line used for generation
swagger-codegen-maven-plugin 0.19.0.2
<configOptions>
<sourceFolder>swagger</sourceFolder>
<library>spring-mvc</library>
<interfaceOnly>true</interfaceOnly>
<useBeanValidation>true</useBeanValidation>
<java8>true</java8>
<serializableModel>true</serializableModel>
<useTags>true</useTags>
</configOptions>
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
The report identifies generated SomeClass and Element models, a Spring MVC POST body, and the useBeanValidation configuration in the Maven plugin. Reproduce the missing Element.someField request with swagger-codegen 0.19.0.2, then inspect the generated validation behavior; done requires a documented or tested expected error path, but no repository file or test is named.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100