Skip to content

Pass full header value with --auth arg #645

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

Closed
mbelsky opened this issue Jun 8, 2021 · 3 comments
Closed

Pass full header value with --auth arg #645

mbelsky opened this issue Jun 8, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@mbelsky
Copy link
Contributor

mbelsky commented Jun 8, 2021

Hey,

Thanks for this solution to make types from oapi jsons.

As I see this tool already supports --auth option and this arg expects to get a token for the Authorization header. However in my case I need to pass a header like Cookie: auth=xxx to get a private schema.

What is your opinion about changing the --auth argument logic from handling just a value for the Authorization header to handle full header value? This implementation will be more flexible for users, but this will be a breaking change for existing users.

The current syntax: npx openapi-typescript --auth "Basic YWxhZGRpbjpvcGVuc2VzYW1l" https://oapi.com/secret-schema.json
The suggested syntax: npx openapi-typescript --auth "Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l" https://oapi.com/secret-schema.json

If you are open to make this change, I will be glad to help with this logic implementation.

@drwpow
Copy link
Contributor

drwpow commented Jun 26, 2021

Hm. I think in that case I’d probably rather add a --header flag with a curl-like syntax, like so: --header "Authorization: …" --header "Content-Type: application-json, etc. That way you just have full control over the headers. And we can keep --auth just as a shortcut.

Would that work?

@drwpow drwpow added the enhancement New feature or request label Jun 26, 2021
@mbelsky
Copy link
Contributor Author

mbelsky commented Jul 2, 2021

Thank you for sharing this solutions. It's a great alternative.

Just one more question, for a command like npx openapi-typescript schema.yaml --auth "token123" --header "Authorization: token789" should the tool use token123 or token789 as an auth token?

In my opinion it should use the token789 token because it comes from a --header flag.

@ericzorn93
Copy link
Contributor

Added in this PR

@drwpow drwpow closed this as completed Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants