0

I use play-swagger + swagger-ui in my project, however I have request with json body like this:

{"country":{"title": "Germany"}}'

When I annotate my method with:

ApiImplicitParam(name = "country[title]", value = "Country's title", required = true, dataType = "String", paramType = "body")

it doesn't work in swagger UI, how can I tell that my title name in country namespace ?

1 Answer 1

1

The best approach would be to define a CountryRequest class (also with annotations) that acts as the model of the request object. Then you would reference this class when defining your ApiImplicitParam. For example,

@ApiModel(value = "CountryRequest")
case class CountryRequest(
  @(ApiModelProperty @field)(dataType = "String", readOnly = false, required = true) title: String,
)

Incidentally, you probably want to define this parameter as a body parameter, so it should look something like this:

@ApiImplicitParams(Array(
  @ApiImplicitParam(name = "body", value = "Country", required = true, dataType = "com.example.CountryRequest", paramType = "body")
))
def postCountry = ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.