-
Notifications
You must be signed in to change notification settings - Fork 29
feat: adding support for server variables #284
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
Conversation
Hmmm okay I like this enough... it's clunky, but there's not much we can really do. I'd love to eventually figure out a way to add shorthand, but I can't think of any way to do that in a deterministic way. (Especially for non-variable servers where, for example, one is a test server and one is real.) It would be nice if eventually (no need to do this now) we could let people specify a x-readme-default server and if there's no variables then we default to that and don't make people spell it out? |
We kind of handle this already by treating the first server in
We could potentially do this as sdk.config({ server: 'Our local development server that runs on localhost:3000' }); We could also treat the servers by their index in the /* oas.servers: [
{ url: 'prod' },
{ url: 'dev' }
] */
sdk.config({ server: 1 });
`` |
Oh great! I don't like the last one (if no other reason, it's possible a swagger creator could switch the order w/o thinking about it, and break tons of APIs!) |
Agreed |
@gkoberger What about changing this to: sdk.server('http://api.example.local:3000/api/') and: sdk.server('https://example.com/{pathParam1}/{pathParam2}', {
pathParam1: 'var1',
pathParam2: 'var2',
}) |
Personally I'm always a fan of explicit config methods such as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just one small comment
🧰 What's being changed?
This adds handling for alternate servers and server variables into a new
.server()
method.api
.createOas
fixture in favor of using fuller OpenAPI examples from @readme/oas-examples.🐳 How does it work?
You can either pass in a full server URL into
server
:Or if you instead want to pass in individual server variable params, you can do so as well:
By default, snippets generated with
httpsnippet-client-api
will be generated with the former syntax.