Path parameters declared as constructor parameters + instance fields = no Parameter in Swagger

151 Aufrufe
Direkt zur ersten ungelesenen Nachricht

James S.

ungelesen,
27.05.2015, 20:10:0527.05.15
an swagger-sw...@googlegroups.com
Hello,

I'm retrofitting an exiting Jersey service to generate Swagger and most of the GET methods are being implemented like this:
Notice how instead of declaring the path parameters as method parameters, they are instead defined as constructors parameters, which set instance fields which then are used in the method body.


@Path("/meetings/ccy")
@Api(value="/meetings/ccy")
public class CentralBankCommitteMeetingDatesByCurrencyResource
{
/**
* The currency code.
*/
private String currencyCode;
/**
* The value date.
*/
private ValueDate valueDate;
/**
* Constructor.
* @param valueDate The value date.
* @param currencyCode The currency code.
*/
public CentralBankCommitteMeetingDatesByCurrencyResource(
@PathParam("valueDate") final String valueDate,
@PathParam("currencyCode") final String currencyCode)
{
this.valueDate = ValueDateParser.parse(valueDate);
this.currencyCode = currencyCode;
}

/**
* Get the meeting dates.
* @return The meeting dates.
*/
@GET
@Path("/{valueDate}/{currencyCode}")
@ApiOperation(value="Get the meeting dates")
@Produces({MediaType.APPLICATION_JSON})
public CentralBankCommitteeMeetingDates get()
{
...
}

}

As it is the generated Swagger does not include these Parameters in the Operation object, even if I add @ApiParam explicitly to go with the @PathParams in the constructor.
I'm not sure why the service developer chose to implement these parameters as instance fields + constructor, but in case this cannot change for some reason, would it be possible to have Swagger generate the parameter somehow?

Thanks,
James

Ron Ratovsky

ungelesen,
27.05.2015, 20:25:2027.05.15
an swagger-sw...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-----------------------------------------
http://swagger.io
https://twitter.com/SwaggerApi
-----------------------------------------
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten