OpenAPITools / OpenAPITools/openapi-generator

[BUG][jaxrs-spec] "exploded" query parameter objects do not generate BeanParam models

Open
#9,129 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I would like to have the ability to define query parameters as objects in my OpenAPI spec and have the jaxrs-spec openapi-generator recognize the that any query parameter of type: object should be exploded by default and generate a @BeanParam model.

For instance, I have this query parameter defined:

    Pagination:
      name: pagination
      description: Pagination details
      in: query
      schema:
        $ref: '#/components/schemas/PaginatedRequest'

Currently, this generates a model that looks like:

public class PaginatedRequest   {
  private @Valid Integer pageSize = 10;
  private @Valid String nextMarker;
  private @Valid String prevMarker;
  private @Valid Boolean defaultOrderAscending = true;

...
}

It would be nice if each of these fields could be annotated with @QueryParam and then I can use PaginatedRequest in my list operations such as:

public listStuff(@BeanParam PaginatedRequest); 

Otherwise, the code generated is incorrect since it will expect that there is a single JSON encoded query parameter instead of "exploding" the parameters as defined in the spec and then using the @BeanParam annotation to group the parameters. After looking through the templates I think this issue applies to all of the Java language generators.

openapi-generator version

5.0.1 of the maven plugin

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the jaxrs-spec templates and the Java language generator behavior for query parameters defined as object schemas. Reproduce the Pagination example with the Maven plugin version described, then compare generated models and list operations with the expected @QueryParam fields and @BeanParam grouping. Done means exploded object query parameters generate a usable BeanParam model rather than a single JSON-encoded parameter, including the other affected Java generators if applicable.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.