OpenAPITools / OpenAPITools/openapi-generator

[BUG][JAXRS-JERSEY2] No injection source found when specifying object as query param

Open
#2,865 2 comments 0 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

Description

I am trying to specify an object as a query parameter, like this:

        - name: filter_options
          description: Filter options
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/FeedbackFilterOptions'
    FeedbackFilterOptions:
      type: object
      properties:
        history_since_type:
          type: string
          enum: [date_time, beginning_of_version]
        history_since_date_time:
          type: string
          format: date-time

This generates a method which contains a FeedbackFilterOptions object.

Jersey complains that it cannot validate this application model, as it doesn't know how to serialise such an object (it cannot find a ParamConverterProvider: see here.

I would have thought that openapi-codegen would generate the relevant converter and allow me to use this object. The way to fix this right now is for me to inline all of the properties of my FeedbackFilterOptions in the query spec, such that each parameter is generated separately as a primitive.

Perhaps I'm missing some Jersey feature which I need to enable?

The full error message:

Caused by: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] No injection source found for a parameter of type public javax.ws.rs.core.Response np1815.feedback.metricsbackend.api.MetricsApi.getFeedbackForFile(java.lang.String,java.lang.String,java.lang.String,np1815.feedback.metricsbackend.model.FeedbackFilterOptions,javax.ws.rs.core.SecurityContext) throws np1815.feedback.metricsbackend.api.NotFoundException at index 3.; source='ResourceMethod{httpMethod=GET, consumedTypes=[], producedTypes=[application/json], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class np1815.feedback.metricsbackend.api.MetricsApi, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@16cf05ef]}, definitionMethod=public javax.ws.rs.core.Response np1815.feedback.metricsbackend.api.MetricsApi.getFeedbackForFile(java.lang.String,java.lang.String,java.lang.String,np1815.feedback.metricsbackend.model.FeedbackFilterOptions,javax.ws.rs.core.SecurityContext) throws np1815.feedback.metricsbackend.api.NotFoundException, parameters=[Parameter [type=class java.lang.String, source=application_name, defaultValue=null], Parameter [type=class java.lang.String, source=version, defaultValue=null], Parameter [type=class java.lang.String, source=filename, defaultValue=null], Parameter [type=class np1815.feedback.metricsbackend.model.FeedbackFilterOptions, source=filter_options, defaultValue=null], Parameter [type=interface javax.ws.rs.core.SecurityContext, source=null, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}']
openapi-generator version

3.3.4

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 generated MetricsApi.getFeedbackForFile method and the FeedbackFilterOptions query parameter shown in the error. Trace how object-valued query parameters are generated for the JAX-RS/Jersey2 server target, then compare that path with separately generated primitive query parameters. Done means the generated application model validates and accepts the object query parameter without the reported injection-source error.

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.