@ApiParam modifications?

417 views
Skip to first unread message

drm...@g.rit.edu

unread,
Mar 5, 2014, 10:19:11 AM3/5/14
to swagger-sw...@googlegroups.com
Theres a couple of things I was wondering if are possible using swagger. First, can you override the type of an ApiParam? Also, can you remove the model/model schema fields in the parameters list? So that if you have a Car class I still want model schema on the end point but it bloats the parameter list and is redundant a lot of times and would be cool if I could remove it. Thanks

tony tam

unread,
Mar 5, 2014, 12:08:30 PM3/5/14
to swagger-sw...@googlegroups.com
Hi, as of 1.3.3-SNAPSHOT, you can mark a Model parameter as hidden:

@ApiModelProperty(hidden=true)
// your getter/setter

The Type override will be supported in 1.3.3 release for both models and @ApiParam annotations.

drm...@g.rit.edu

unread,
Mar 5, 2014, 2:39:27 PM3/5/14
to swagger-sw...@googlegroups.com
Ok cool, Another thing I'm wondering about is that it seems that in the Model Schema/Model that whenever it parses parameter that is an object, it appends it's model which is something that I do not want. Anything that can be done about that?

tony tam

unread,
Mar 5, 2014, 3:20:32 PM3/5/14
to swagger-sw...@googlegroups.com
Well, that's the whole idea.  What good would it be to have a "User" object with an unknown "Address" object buried inside it?  Swagger will scan the dependencies and append them to the model as well.  Is it getting them wrong?

Twinkle

unread,
Oct 24, 2015, 1:07:29 AM10/24/15
to Swagger
Hi Tony, i have a requirement where i dont want to use all the parameters of nested object. How can i modify the body schema so that it would contains only necessary fields.

tony tam

unread,
Oct 24, 2015, 1:08:13 AM10/24/15
to swagger-sw...@googlegroups.com
Can you please give a simple example?

On Oct 23, 2015, at 10:07 PM, Twinkle <jassyt...@gmail.com> wrote:

Hi Tony, i have a requirement where i dont want to use all the parameters of nested object. How can i modify the body schema so that it would contains only necessary fields.

--
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.

Twinkle

unread,
Oct 24, 2015, 1:27:29 AM10/24/15
to Swagger
Thanks for you quick reply :)

Assume user model schema is like below :

{
  "firstName": "string",
  "lastName": "string",
  "ids": [
    "string"
  ],
  "birthDetails": {
    "place": "string",
    "date": "string"
  },
  "address": {
    "homeAAddress": {
      "postalCode": "string",
      "place": "string"
    },
    "officeAAddress": {
      "postalCode": "string",
      "place": "string"
    }
  }
}

birthDetails and homeAAddress fields are not required in request. How i can avoid or hide them in model schema
Note : not use @ApiModel annotation

So that i would get :
{
  "firstName": "string",
  "lastName": "string",
  "ids": [
    "string"
  ],
  "address": {
    "homeAAddress": {
      "postalCode": "string",
      "place": "string"
    }
  }
}

as my model schema while using tryOut option





On Saturday, October 24, 2015 at 9:08:13 AM UTC+4, tony tam wrote:
Can you please give a simple example?
On Oct 23, 2015, at 10:07 PM, Twinkle <jassyt...@gmail.com> wrote:

Hi Tony, i have a requirement where i dont want to use all the parameters of nested object. How can i modify the body schema so that it would contains only necessary fields.

--
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-swaggersocket+unsub...@googlegroups.com.

tony tam

unread,
Oct 24, 2015, 1:35:05 AM10/24/15
to swagger-sw...@googlegroups.com
You can use @ApiModelProperty(hidden = true) on the property.  Won’t that work?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Twinkle

unread,
Oct 24, 2015, 1:40:38 AM10/24/15
to Swagger
Model schema is getting generated automatically. I am not using @ApiModel on my models.

Please check below my sample resource :
    @POST
    @Path("/create")
    @ApiOperation(notes = "create user", value = "create user")
    public Response createUser(UserDTO user) {
        // ...
        return responseBuilder.build();
    }

Can i hide above mentioned parameters here ??

tony tam

unread,
Oct 24, 2015, 1:46:17 AM10/24/15
to swagger-sw...@googlegroups.com
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Twinkle

unread,
Oct 25, 2015, 7:52:57 AM10/25/15
to Swagger
Please find my Filter code below :

    @Override
    public boolean isParamAllowed(Parameter parameter, Operation operation,
            ApiDescription api, Map<String, List<String>> params,
            Map<String, String> cookies, Map<String, List<String>> headers) {

        // do not allow the documentation to be generated on parameters that
        // have their access set to "internal"
        if (parameter.getAccess() != null
                && parameter.getAccess().equalsIgnoreCase("internal")) {
            LOGGER.debug("The following parameter has been hidden from the Swagger API documentation: "
                    + parameter.getDescription());
            return false;
        } else {
            return true;
        }
    }


If I have only one parameter object, e.g. UserDTO then how I could put "access" on one property of user ?? Please help.
Reply all
Reply to author
Forward
0 new messages