-1

I am using swagger to show the variables that a user need to provide for my api endpoint. I am using a model class to which the swagger ui refers for the parameter list to display for the particular endpoint, Consider I use the same model for a POST call action and PUT call action but I need to hide a particular variable in my model from swagger docs for POST and to have it for PUT call. To be clear user should not see "transactionId" in swagger ui for my POST action but should see it for PUT action.

MrTesla
  • 99
  • 2
  • 9

1 Answers1

1

Use [IgnoreDataMember] in your model for the transactionId See more information here:

How can we hide a property in WebAPI?

Are you looking for this?

Mike
  • 174
  • 1
  • 11
  • If I use `[IgnoreDataMember]` the variable won't be available for both POST and PUT, but I require it for PUT call and not for the POST call. @Mike – MrTesla Feb 07 '19 at 06:20
  • Have a look at this post: https://forums.servicestack.net/t/swagger-ignore-property-for-certain-verbs/2167 Probably it will help you. Best way to do it, is just to seperate the models for each verb. – Mike Feb 07 '19 at 06:28