swagger-api / swagger-api/swagger-codegen

Error with Jersey: java.text.ParseException: Expected separator ';' instead of ','

Open
#4,892 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Not sure, if it is a swagger issue or Jersey but my REST API's @Consumes and @Produces values are comma separated like:
application/json,application/abc.def.ghi+json,application/abc.def.ghi.v1+json

It works fine with default okhttp but if we use Jersey2 we are seeing following error:
{
"dateLibrary": "java8",
"library": "jersey2",
}

Exception in thread "main" java.lang.IllegalArgumentException: Error parsing media type 'application/json,application/abc.def.ghi+json,application/abc.def.ghi.v1+json'
at org.glassfish.jersey.message.internal.MediaTypeProvider.fromString(MediaTypeProvider.java:92)
at org.glassfish.jersey.message.internal.MediaTypeProvider.fromString(MediaTypeProvider.java:60)
at javax.ws.rs.core.MediaType.valueOf(MediaType.java:179)
at javax.ws.rs.client.Entity.entity(Entity.java:100)
at com.abc.client(ApiClient.java:490)
at cms.AccessTokensApiExample.main(AccessTokensApiExample.java:26)
Caused by: java.text.ParseException: Expected separator ';' instead of ','
at org.glassfish.jersey.message.internal.HttpHeaderReader.nextSeparator(HttpHeaderReader.java:146)
at org.glassfish.jersey.message.internal.HttpHeaderReader.readParameters(HttpHeaderReader.java:306)
at org.glassfish.jersey.message.internal.HttpHeaderReader.readParameters(HttpHeaderReader.java:296)
at org.glassfish.jersey.message.internal.MediaTypeProvider.valueOf(MediaTypeProvider.java:118)
at org.glassfish.jersey.message.internal.MediaTypeProvider.fromString(MediaTypeProvider.java:90)
... 7 more

Swagger-codegen version

2.2.0

Swagger declaration file content or url
Command line used for generation
Steps to reproduce

Generate client using Jersey like
{
.
.
.
"dateLibrary": "java8",
"library": "jersey2",
}

Related issues
Suggest a Fix

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 by reproducing the Jersey2 client generation described in the issue, then inspect the generated ApiClient.java at line 490 and the Jersey media-type handling shown in the stack trace. Compare the generated @Consumes and @Produces values with the working okhttp behavior. Done means comma-separated media types are accepted by the Jersey client and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.