Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JSON-B @JsonbProperty in generated documentation #2789

Open
ghost opened this issue May 2, 2018 · 5 comments
Open

Support JSON-B @JsonbProperty in generated documentation #2789

ghost opened this issue May 2, 2018 · 5 comments

Comments

@ghost
Copy link

ghost commented May 2, 2018

Q A
Bug or feature request? feature request
Which Swagger-Core version? 2.0.0
Which Java version? Java 8
Which JAX-RS framework & version? 2.0

The JSON-B annotation javax.json.bind.annotation.JsonbProperty can be used to set a different property name for a JSON property much like the jackson annotation com.fasterxml.jackson.annotation.JsonProperty can.

@javax.json.bind.annotation.JsonbProperty(value = "_name1")
private String name1;

@com.fasterxml.jackson.annotation.JsonProperty (value = "_name2")
private String name2;

When using the jackson annotation the name is automatically used in the generated swagger documentation.

The generated documentation should also reflect the property name set with the JSON-B annotation.

@idefixcert
Copy link

Is there a workaround for that, I also have the same problem.

@anachronoxLF
Copy link

Hi,
i faced the same problem. Simple, but very ugly workaround is to add @Schema annotation
e.g.

public static final String JSON_ATTRIBUTE_ID = "_id";
...
@Schema(name = JSON_ATTRIBUTE_ID)
@JsonbProperty(JSON_ATTRIBUTE_ID)
private Long id;

Other solution I found was to use Jackson annotations instead of JSON-B annotations. The JAX-RS implementation I work with (RESTEasy in Wildfly) can use Jackson annotations for JSON serialization/deserialization out-of-the-box (without any configuration needed).
But I try to be not dependent on specific implementations of EE 8 API technologies, therefore I use the solution with @Schema

@bcluap
Copy link

bcluap commented Jun 7, 2019

+1 for Swagger to read @JsonbProperty

@rallampalli
Copy link

I am using swagger plugin to generate classes from api spec (yaml) file. The generated model classes contains Jackson annotations. I would like to have JSON-B annotations instead of Jackson annotations. How this can be achieved?

@l-ray
Copy link

l-ray commented Aug 29, 2021

+1 for Swagger to read @JsonbProperty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants