OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA][Spring HATEOAS] Generated collection has wrong type. LIst instead of CollectionModel
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
I try to use Generator together with spring HATEOAS. It is generating me interface method with looks like this:
ResponseEntity<List<Item>> getItem();
Item class is generated correctly to support HATEOAS:
public class Item extends RepresentationModel<Item>
The problem is that method returns a List<Item> instead of : org.springframework.hateoas.CollectionModel<T> so finally Spring HATEOAS is not creating correct HAL response body.
Can I somehow force generator to use CollectionModel instead of List?
Documentation: 2.4.2. Collection resource representation mode
openapi-generator version
5.0.0
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
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
No source file, test, OpenAPI declaration, or generation command is provided. Start by reproducing the generated Java interface with Spring HATEOAS and trace how collection response types are selected. Done means collection methods use Spring HATEOAS CollectionModel rather than List and produce the expected HAL response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100