0

Is it possible to Swagger a Get Api with one parameter that can be different in name? I Explain, I should create a controller that can have this behaviour:

GET <MySite>/suppliers?srm=0016018132
GET <MySite>/suppliers?vat=02123420040

srm and vat are mutually exclusive. A user can call one of two form of the api.

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
Max Bertoli
  • 614
  • 5
  • 25
  • 1
    Edit the title to reflect the question. You aren't asking about WebAPI parameters. You're asking whether OpenAPI can express that two parameters are mutually exclusive. – Panagiotis Kanavos Jun 23 '21 at 13:42
  • Does this answer your question? [How to define mutually exclusive query parameters in Swagger (OpenAPI)?](https://stackoverflow.com/questions/21134029/how-to-define-mutually-exclusive-query-parameters-in-swagger-openapi) – Panagiotis Kanavos Jun 23 '21 at 13:45

1 Answers1

0

short answer

no

a little longer answer

where in c# a method's "uniqueness" derives from the name and parameter order/type, in a web api only a method's name determines "uniqueness".

Shai Cohen
  • 6,074
  • 4
  • 31
  • 54
  • The question is really about Open API, not method parameters. One can write validation code to express any kind of restriction. It's possible to create middleware that does the same. The real question is if that can be expressed in the Open API document – Panagiotis Kanavos Jun 23 '21 at 13:44
  • @PanagiotisKanavos - I respectively disagree. Open Api is generated *from* the Controller's Actions. Actions are fancy names for methods. It's also a *bit* presumptuous of you to dictate to the OP and myself what you *want* the question to be about. – Shai Cohen Jun 23 '21 at 15:49
  • Check [How to define mutually exclusive query parameters in Swagger (OpenAPI)?](https://stackoverflow.com/questions/21134029/how-to-define-mutually-exclusive-query-parameters-in-swagger-openapi). Generating an Open API document from actions is just one way to do it but not the most flexible. So the short answer is *Yes, more or less* – Panagiotis Kanavos Jun 24 '21 at 06:05