swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.37k stars 2.17k forks source link

Can jaxb generate swagger annotations? #2120

Open shmersy opened 7 years ago

shmersy commented 7 years ago

Hi, In my project I generate java dto from xsd thanks to maven-jaxb2-plugin.

example of generated dto :

@XmlRootElement(name = "createItem") public class CreateItem {

@XmlElement(required = true)
@NotNull
protected String name;

}

I generate a swagger documentation but the description remains empty. I'm looking for a solution to add description to swagger documentation.

In a static java dto I would simply add @ApiModelProperty and it works but since my java calsses are generated by jaxb if I add @ApiModelProperty it will be deleted.

Can Jaxb generate swagger annotations?

Can you please help? Another solution is more than welcome...

webron commented 7 years ago

Read (the full) https://github.com/swagger-api/swagger-core/issues/960 ticket.

shmersy commented 7 years ago

I am sorry, I have read the ticket but it does not respond to my question...

let me simplify my question again :

I have this xsd :

when I generate the java classe the result is this : @XmlRootElement(name = "createItem") public class CreateItem { @XmlElement(required = true) @NotNull protected String name; } But actually I need to generate this : @XmlRootElement(name = "createItem") **@ApiModel**(value = "CreateItem", description = "description goes here") public class CreateItem { @XmlElement(required = true) @NotNull @**ApiModelProperty**(value = "name", required = true) protected String name; } How? NB : I used jhipster to generate my (spring boot) project. and "swagger2markup-maven-plugin" to generate the swagger doc Thanks
webron commented 7 years ago

If you're not using swagger-core directly, then open the ticket on the project that generates your spec. Swagger-core does not work at compile time, and other tools utilize parts of it to do so, but it's their responsibility to make sure the processing is done correctly. If they think there's an issue with swagger-core, they will (and have) open a ticket here.

shmersy commented 7 years ago

This is more like a question than an ticket :) as I don't find much doc on the net but ok I will. Thanks anyway

tamilmanam1 commented 5 years ago

I am also generating the model using jaxb2-maven-plugin for spring boot application. The swagger documentation generated for the model class has the below. I would like add a description and remove the bold text. Any help will be appreciated.

decision string xml: OrderedMap { "name": "decision", "attribute": false, "wrapped": false } xml: name: decision attribute: false wrapped: false

ahoehma commented 4 years ago

Hi all ... I would like to ask if its possible to hide this "xml:" stuff completely? I don't see any necessary information there.