Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Configuration for global Operation-Parameters #845

Closed
GitVhaos opened this issue Jul 14, 2015 · 10 comments
Closed

[Question] Configuration for global Operation-Parameters #845

GitVhaos opened this issue Jul 14, 2015 · 10 comments
Labels
Milestone

Comments

@GitVhaos
Copy link
Contributor

Im currently working on an internal API which uses two "parameters" for authentication. These two parameters have to be sent for each request to authenticate the user. The authentication mechanism is place in one central place, so no Spring Controller has these two parameters as its request-parameters. In Swagger (-UI) these parameters are now missing as Input Parameters.

In my opionion it`s no option to annotate every Controller with Swagger-Annotations declaring these parameters. Later developer will miss to configure it on new controllers. Also in a future api version I maybe want to change my authentication type without editing each Controller.

Is there an option (maybe via Docket) to configure parameters which will be added to each operation in swagger documentation?

I`m searching for something like this:

return new Docket(DocumentationType.SWAGGER_2)
.select().build()
.addGlobalRequestParameter(String.class, "user")
.addGlobalRequestParameter(Integer.class, "department");

@dilipkrish dilipkrish added this to the Someday milestone Jul 14, 2015
@dilipkrish
Copy link
Member

Thats a great idea. Would you like to take a shot at implementing it?

@GitVhaos
Copy link
Contributor Author

I will give it a try!

@GitVhaos
Copy link
Contributor Author

In ParameterMerger it seems that usage of "destination" and "source" is mixed (e.g. usage of "asIsParameters()" method).
Can u please check this? I think "destination" is correct and method signature only needs to be renamed.

@GitVhaos GitVhaos changed the title [Question] Configuration for global Request-Parameters [Question] Configuration for global Operation-Parameters Jul 20, 2015
@GitVhaos
Copy link
Contributor Author

@dilipkrish I created a pull request for this feature.
[Pull-Request|https://github.com//pull/861]

@GitVhaos
Copy link
Contributor Author

GitVhaos commented Sep 7, 2015

@dilipkrish This feature is already merged with #861 and can be closed as duplicate.

@dilipkrish dilipkrish modified the milestones: 2.3.0, Someday Sep 9, 2015
@dilipkrish
Copy link
Member

This feature has been already implemented! via #861

GitVhaos added a commit to GitVhaos/springfox that referenced this issue Oct 12, 2015
GitVhaos added a commit to GitVhaos/springfox that referenced this issue Oct 12, 2015
dilipkrish added a commit that referenced this issue Oct 15, 2015
Springfox #845: Configuration for global Operation-Parameters. (Documentation)
@jihlee
Copy link

jihlee commented Feb 2, 2016

This is great contribution :) I recently started using SpringFox and this feature was inevitable to use OAuth2 as authentication method for my system.

My question is, is it possible to exclude some specific methods for this configuration? All of my API methods should include 'Authorization' header except some authentication related APIs.

At the moment, I could not find the way to achieve that so my authentication API also requires 'Authorization' header which is not nice. Is there any chance to configure this kind of setup?

Thanks!

@GitVhaos
Copy link
Contributor Author

GitVhaos commented Feb 2, 2016

Hi Jihun,
happy to hear that my contribution is also helpful for other people! 
Unfortunately I didn't had ur use case in our api. Cause we need authentication informations on every service.
You need to extend the current docket implementation to Support ur feature. I thought about a suggestion, but no "beautiful" way came to my mind...
Maybe you can replace "parameter" type with you own "GlobalParameter" type, which consist of "parameter" and a list of excluded "paths".
Regards Sven

Von meinem Samsung Gerät gesendet.

-------- Ursprüngliche Nachricht --------
Von: Jihun Lee notifications@github.com
Datum: 02.02.2016 08:14 (GMT+01:00)
An: springfox/springfox springfox@noreply.github.com
Cc: GitVhaos schulzsv@arcor.de
Betreff: Re: [springfox] [Question] Configuration for global
Operation-Parameters (#845)

This is great contribution :) I recently started using SpringFox and this feature was inevitable to use OAuth2 as authentication method for my system.

My question is, is it possible to exclude some specific methods for this configuration? All of my API methods should include 'Authorization' header except some authentication related APIs.

At the moment, I could not find the way to achieve that so my authentication API also requires 'Authorization' header which is not nice.


Reply to this email directly or view it on GitHub.

@dilipkrish
Copy link
Member

@jihlee A simple way to fix this is to have multiple dockets. One for all the other services and one for the login/logout endpoints. The login/logout endpoints don't add the global parameters

@puce77
Copy link

puce77 commented May 18, 2020

@dilipkrish unfortunately, multiplie dockets also means multiple group names

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants