Skip to content

Conversation

@erunion
Copy link
Member

@erunion erunion commented Oct 17, 2023

🚥 Resolves #676

🧰 Changes

This slightly changes the installation process to now prompt the user if they would like to install their SDK using the info.title value from the API definition they supplied:

Screen Shot 2023-10-16 at 5 33 24 PM

Note that this work only applies if they supply a non-ReadMe API Registry value to npx api install:

npx api install --identifier buster demo.json # will continue to use "buster"
npx api install @developers/v2.0#17273l2glm9fq4l # will continue to use "developers"
npx api install demo.json # will prompt the user if they want to use `info.title`

@erunion erunion added enhancement New feature or request area:api Issues related to the `api` CLI, which builds the SDKs labels Oct 17, 2023
// what they want.
({ value: identifier } = await promptForIdentifier(false));
}
} else {
Copy link
Member Author

@erunion erunion Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should never get to this else case because info.title is required in an OpenAPI definition but just in case we don't have it for whatever reason, we'll just fallback to asking them what they want -- though codegen will likely fail immediately after this because of their invalid spec.

@erunion erunion marked this pull request as ready for review October 17, 2023 00:43
@erunion erunion added this to the v7 milestone Oct 17, 2023
@erunion erunion requested a review from kanadgupta October 17, 2023 00:43
Copy link
Contributor

@kanadgupta kanadgupta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good but I was thinking we do this with a different prompt flow where we prompt the user for the identifier, but rather than having two questions to handle this, we have one question (i.e., 'What would you like to identify this API as?') with the initial value set to the slugified info.title field. This would be spiritually similar to how we have a sensible initial value when reducing a spec file in rdme:

https://github.com/readmeio/rdme/blob/b8046fb083815924c51e3dbf7c419ea0a8e7ae6c/src/cmds/openapi/reduce.ts#L168-L175

Let me know what you think! I like how it's fewer prompts/keypresses with my idea, but I do like the explicitness of your approach

@erunion
Copy link
Member Author

erunion commented Oct 17, 2023

Revised this a bit and now there's just a single identifier question with a new initial value based on info.title if it's present.

Screen Shot 2023-10-17 at 9 59 30 AM

@erunion erunion requested a review from kanadgupta October 17, 2023 18:01
Co-authored-by: Kanad Gupta <8854718+kanadgupta@users.noreply.github.com>
@erunion erunion merged commit e93078e into main Oct 18, 2023
@erunion erunion deleted the feat/prefill-cli-identifier branch October 18, 2023 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:api Issues related to the `api` CLI, which builds the SDKs enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prefill the identifier with api.info.title

3 participants