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

[BUG] Ruby Client generates docs that encourage bad client configuration. #5367

Open
5 of 6 tasks
davinchia opened this issue Feb 19, 2020 · 1 comment
Open
5 of 6 tasks

Comments

@davinchia
Copy link

davinchia commented Feb 19, 2020

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

The ruby client documentation encourages the use of the default client constructor. This is fine in most cases, but does carry the caveat that the default constructor will use the later given access_token across all threads. Passing access_token to constructors avoids this.

This is because the configure method modifies a @@default variable which is passed as the default argument to the initialize method for DefaultApi.

Not a ruby expert - so can't comment on whether the generated code follows the right ruby patterns/conventions. I do think this can be avoided with tweaks in the documentation that accompanies the generated client.

openapi-generator version

Using 4.2.1.

OpenAPI declaration file content or url

NA.

Command line used for generation

NA.

Steps to reproduce

Generate any client and look at the rendered documentation.

Related issues/PRs

Checked. Unclear from my 10 mins search.

Suggest a fix

Not an expert on the ruby generation bit of this codebase. Open to pointers. Filing an issue for myself now. Will likely get to it when I have some time.

@davinchia davinchia changed the title [BUG] Ruby Client generates docs that encourage bad client configuration. [BUG] Ruby Client generates docs encourage bad client configuration. Feb 19, 2020
@davinchia davinchia changed the title [BUG] Ruby Client generates docs encourage bad client configuration. [BUG] Ruby Client generates docs that encourage bad client configuration. Feb 19, 2020
@lisamburns
Copy link
Contributor

I have this same issue. I don't want the access token to be global and so reading the generated code, it looks like I need to do something like this, nonintuitively.
config = MyService::Configuration.new(
access_token: "some-token"
)
api = MyService::DefaultApi.new(MyService::ApiClient.new(config))

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

No branches or pull requests

2 participants