Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Arbitrary mapping of ApiModelProperty fields #44

Open
afiore opened this issue Oct 27, 2014 · 3 comments
Open

Arbitrary mapping of ApiModelProperty fields #44

afiore opened this issue Oct 27, 2014 · 3 comments

Comments

@afiore
Copy link

afiore commented Oct 27, 2014

Hi there,
I have the following model definition:

 case class OfferQuery(
     @(ApiModelProperty @field)
     pricePerWeek: Int,
     @(ApiModelProperty @field)(required = true)
     resultNum: Int = 200)

Is there any annotation/override mechanism whereby I can have swagger generate the following JSON output?

 { "price_per_week": ...,
   "result_num": ...}

Thanks a lot,
Andrea

@mhamrah
Copy link
Contributor

mhamrah commented Oct 27, 2014

Based on the code here:
https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-annotations/src/main/java/com/wordnik/swagger/annotations/ApiModelProperty.java
I think the answer is no, but you can try looking at the swagger-core
mailing list. Spray-swagger uses the underlying swagger-core library for
reading annotations and building the model response. I can say
spray-swagger doesn't explicitly provide this, and a cursory glance through
the swagger-core code (
https://github.com/swagger-api/swagger-core/blob/7d73179cc0f9717404d3f1907a64998a7948d38a/modules/swagger-core/src/main/scala/com/wordnik/swagger/converter/ModelPropertyParser.scala)
looks like this isn't supported, but there may be an alternate way.

If you find a solution, please post back and I can add to the docs.

On Mon, Oct 27, 2014 at 2:14 PM, Andrea Fiore notifications@github.com
wrote:

Hi there,
I have the following model definition:

case class OfferQuery(
@(ApiModelProperty @field)
pricePerWeek: Int,
@(ApiModelProperty @field)(required = true)
resultNum: Int = 200)

Is there any annotation/override mechanism whereby I can have swagger
generate the following JSON output?

{ "price_per_week": ...,
"result_num": ...}

Thanks a lot,
Andrea


Reply to this email directly or view it on GitHub
#44.

@afiore
Copy link
Author

afiore commented Oct 27, 2014

Thanks for your quick reply! Will certainly let you know if I find a decent solution.

A

@bthibault
Copy link

Pinging here .... https://github.com/swagger-api/swagger-core/wiki/overriding-models ... looks like swagger does support overriding models now.

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

No branches or pull requests

3 participants