Reputation: 175
I have a sample github using springdoc : https://github.com/vmisra2018/sb-example-swaggerdoc and I can't figure out how can I enable X-Forwarded-For for any api eg:" /person " when i click try-it-out
To Reproduce Steps to reproduce the behavior:
version of spring-boot=> 2.2.2.RELEASE
modules and versions of springdoc-openapi =>springdoc-openapi-ui:1.2.32
I have below entry as per https://springdoc.org/faq.html and also defined ForwardedHeaderFilter bean,
server:
forward-headers-strategy: NATIVE
Sample code: https://github.com/vmisra2018/sb-example-swaggerdoc
Expected behavior I want to see X-Forwarded-For header when i click try-it-out in swagger-ui.html. I dont see it.
Upvotes: 1
Views: 2340
Reputation:
X-Forwarded-For is set by web servers in general ... If your application exposes this Header it can be avaialble on the swagger-ui without any issue.
For the Authorization Header the cause is different, The OpenAPI 3 specification does not allow explicitly adding Authorization header. For more information, please read:
Note: Header parameters named Accept, Content-Type and Authorization are not allowed. To describe these headers
https://swagger.io/docs/specification/describing-parameters/#header-parameters.
Upvotes: 0
Reputation: 175
It was just a matter of adding parameter. I got hint from here : Authorization Header not getting displayed in CURL springdoc-openapi-ui
Documentation is confusing for a new person. The one that is explained in faq is for enabling x-forwarded-for but iis it for swagger-ui? The purpose of swaggerui plugin for me was to display api and be able to test ap and I simply wanted to pass x-forwarded-for from swagger-ui and I kept on searching for it. Solution is in fix-xforwardedfor-swaggerdoc branch github
Upvotes: 0