Swagger-core: hiding parameters

Created on 6 Feb 2013  路  9Comments  路  Source: swagger-api/swagger-core

I am using swagger with jersey.

Is there a way to hide parameters that we don't want shown on the api being generated. That is, is there a way to prevent certain @QueryParam or @HeaderParam from being added to the list of parameters being generated.

Most helpful comment

@ApiIgnore @RequestParam(value= DEBUG_MODE,...)
Working for me.

All 9 comments

Internally we use the access value in the annotation to hide them--we set access="internal" and let a filter look at the permissions of the user making the call (per api_key and auth_token) to make sure they're visible. I'll look at the filter logic to see if we can expose it in the core project.

thanks for the quick response. I have another question relating to hiding a parameter.

I have the following code:
(@ApiParam(access = "internal" , required = false)@InjectParam final DefectSearchBeanV1 searchBean

It works without the @ApiParam annotation but when I include it, my rest service breaks and the endpoint gives HTTP Status 415 - Unsupported Media Type.

can you help make a test case? The @ApiParam shouldn't affect this at all.

Sorry. What do you mean by writing a test case. Are you looking for a junit? Is there a sample that I can follow?

2nd that. This enhancement will be very useful

This is in the 1.3-develop branch, see this test case:

https://github.com/wordnik/swagger-core/blob/develop-1.3/modules/swagger-core/src/test/scala/filter/SpecFilterTest.scala#L44

Should be very easy to support this now.

pushed as 1.3.0-SNAPSHOT

I can't get this working. I have a header param annotated with

@ApiParam(access="internal", required=false) @HeaderParam(HeadersNames.API_ID) @Pattern(regexp = RegularExpressions.REGEXP_OBJECT_ID) String appId

The param is always present in the generated JSON.

{
"name":"Object-Id",
"required":false,
"allowMultiple":false,
"type":"string",
"paramType":"header",
"paramAccess":"internal"
}

And it is shown in swagger-ui

It's swagger-ui failing? Did I miss something?

Thanks in advance

@ApiIgnore @RequestParam(value= DEBUG_MODE,...)
Working for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yntelectual picture yntelectual  路  3Comments

jmilkiewicz picture jmilkiewicz  路  4Comments

YLombardi picture YLombardi  路  4Comments

denny99 picture denny99  路  4Comments

NathanStrong-Tripwire picture NathanStrong-Tripwire  路  3Comments