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

[Tracking issue] Generating client code from the OpenAPI schema #1157

Closed
indigok opened this issue Oct 3, 2019 · 7 comments
Closed

[Tracking issue] Generating client code from the OpenAPI schema #1157

indigok opened this issue Oct 3, 2019 · 7 comments
Labels
Status: Stale Used by stalebot to clean house Type: Feature New feature or request

Comments

@indigok
Copy link

indigok commented Oct 3, 2019

Opening this to track the progress of generating the client code from the OpenAPI spec in the shared routes directory.

👀 #1010 for proof of concept
👀 octokit/routes#168 for more context

@zeke
Copy link

zeke commented Oct 11, 2019

Wow! So cool to see this happening.

cc @sarahs @jleaver

@indigok
Copy link
Author

indigok commented Oct 29, 2019

Octokit.rb has a stable release of v4 on the branch 4-stable. These PRs will now be merged into master as we build up v5 🚀

@indigok
Copy link
Author

indigok commented May 26, 2020

With the current naming schema, we’ve generated 33/91 clients. Thus, as we’ve reached a third of the way through the project and finally have several moving parts solidified, I’m going to take a moment to write some documentation.

Steps to generate a new client

  1. Have both octokit/routes and octokit/octokit.rb in the same directory. Everything else will be run from inside of octokit.rb
  2. Add the client you want to generate to the supported resources. The client names mirror the documentation url after v3, i.e. pull request comments go from https://developer.github.com/v3/pulls/comments/ to pulls_comments.
  3. Run bundle exec rake generate
 to generate all the clients listed in the above line from the openapi spec.
  4. Compare the diff and see if the generated client has any mistakes. The old clients will likely be in a different file but try to find all the corresponding methods - checking the documentation link is a good way to ensure you're finding the right ones. The clients don’t have to be an exact match but should be understandable and useable.
  5. Change anything you need to in openapi_client_generator. A high risk area is the namespace method. As the API becomes more standardized, hopefully we can reassess this method but as it stands, it’s one of the hardest parts to generate and there’s a lot of special casing. binding.pry is your friend.
  6. Regenerate and tweak the generator as needed until you feel comfortable pushing and merging it 🚀

Tests

The new way of testing is outlined in #1258. Ideally, if you’re working on a client that contains one of these scenarios, go ahead and add the matching test.

Openapi schema

This generator is currently being pulled from octokit/routes which scrapes the developer docs. In the near future, the new source of truth will be openapi and we’ll need to make the switch. The main change appears to be switching from a JSON to a YAML schema, but most of the fields are the same.

Additionally, useful parts to understand in the openapi structure, as referenced in octokit/routes, are the index file which shows the paths under operations to each endpoint. These two areas help provide you with all the information you have to generate the SDK.

@zeke
Copy link

zeke commented May 26, 2020

Thanks for the update @hmharvey 👍

In the near future, the new source of truth will be openapi and we’ll need to make the switch. The main change appears to be switching from a JSON to a YAML schema, but most of the fields are the same.

FYI the built definitions files are still JSON. See https://unpkg.com/browse/@github/[email protected]/dist/

@indigok
Copy link
Author

indigok commented May 27, 2020

FYI the built definitions files are still JSON. See https://unpkg.com/browse/@github/[email protected]/dist/

Aha so they are! Thanks pointing that out 🙇🏻‍♀️

This was referenced Jul 7, 2020
@indigok indigok changed the title [Tracking issue] Generating client code from octokit/routes [Tracking issue] Generating client code from the OpenAPI schema Jul 7, 2020
@maxandersen
Copy link

tried follow the instructions in "#1157 (comment)" but I get:

 bundle exec rake generate
rake aborted!
Don't know how to build task 'generate' (See the list of available tasks with `rake --tasks`)

nor can I find languages mentioned in https://github.com/octokit/octokit.rb/blob/master/lib/openapi_client_generator.rb?rgh-link-date=2020-05-26T23%3A17%3A40Z#L408

was this removed / moved ?

@nickfloyd nickfloyd added Type: Feature New feature or request and removed feature labels Oct 28, 2022
@github-actions
Copy link

👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

@github-actions github-actions bot added the Status: Stale Used by stalebot to clean house label Jul 27, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Used by stalebot to clean house Type: Feature New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants