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

feat(openapi): add update option to automatically update an only available spec file without any prompts #579

Merged
merged 11 commits into from
Aug 23, 2022

Conversation

shaiarmis
Copy link
Contributor

Today when using the rdme openapi <path> --version=<version> command to update a spec file (selecting Update in the first prompt), we're prompted for selecting an API spec file, even if there's only a single one present.

🧰 Changes

This PR adds the --updateSingleSpec option that will instruct the CLI to not prompt the user if there's only a single spec file available, and choose it automatically.

🧬 QA & Testing

  1. Start with a clean project with no API spec files at all
  2. Run rdme openapi <path> --version=<version>, which will upload the file without any create/update prompt because there's nothing to update.
  3. Run rdme openapi <path> --version=<version> once again, and select update in the first prompt and expect to see another prompt with a single option.
  4. Abort the previous command.
  5. Run rdme openapi <path> --version=<version> --updateSingleSpec and expect the file to upload successfully without any prompts.

@domharrington
Copy link
Member

Thanks for this! I'm gunna assign to @kanadgupta as he's the person primarily responsible for managing this repo. I think we already have some things in the works to help with this, but i'll see what Kanad says.

Copy link
Member

@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.

Thanks for the PR! Can you add two pieces of logic (and corresponding test cases):

  • An error message if a user passes this --updateSingleSpec flag but apiSettingsBody.length is greater than 1
  • A warning output if a user passes in the --id parameter AND the --updateSingleSpec flag (similar to this)

README.md Show resolved Hide resolved
@kanadgupta
Copy link
Member

Also—please ignore the failing GitHub Action Dry Run step since that's a known issue with external contributors—but if you could fix the failing snapshots in the Test Suite, that'd be great. Thank you!

@shaiarmis
Copy link
Contributor Author

Also—please ignore the failing GitHub Action Dry Run step since that's a known issue with external contributors—but if you could fix the failing snapshots in the Test Suite, that'd be great. Thank you!

Done

@shaiarmis
Copy link
Contributor Author

Thanks for the PR! Can you add two pieces of logic (and corresponding test cases):

  • An error message if a user passes this --updateSingleSpec flag but apiSettingsBody.length is greater than 1
  • A warning output if a user passes in the --id parameter AND the --updateSingleSpec flag (similar to this)

Done x 2

@erunion erunion added enhancement New feature or request command:openapi Issues pertaining to the `openapi`, `validate`, `reduce`, or `swagger` commands labels Aug 23, 2022
Copy link
Member

@erunion erunion left a comment

Choose a reason for hiding this comment

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

thanks for this!

@@ -96,6 +102,12 @@ export default class OpenAPICommand extends Command {
Command.warn("We'll be using the `--create` option , so the `--id` parameter will be ignored.");
}

if (updateSingleSpec && id) {
Command.warn(
'When using the `--id` option the `--updateSingleSpec` option is ignored, as the desired spec id is already specified.'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'When using the `--id` option the `--updateSingleSpec` option is ignored, as the desired spec id is already specified.'
'When using the `--id` option the `--updateSingleSpec` option is ignored as the desired spec is already specified.'

@kanadgupta kanadgupta requested a review from erunion August 23, 2022 16:28
Copy link
Member

@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.

Made a few copy edits and added a tiny error case. Thanks again for the PR @shaiarmis!

@shaiarmis
Copy link
Contributor Author

@kanadgupta thanks for the additional changes, they make a lot of sense :)
Should I wait for @erunion's approval before merging this PR?

@shaiarmis
Copy link
Contributor Author

LOL just realized I don't have permissions to merge ^_^ So go ahead and merge at your leisure.

@kanadgupta kanadgupta merged commit ff766a6 into readmeio:main Aug 23, 2022
@kanadgupta kanadgupta changed the title feat(openapi): Add updateSingleSpec option to automatically update an only available spec file without any prompts feat(openapi): add update option to automatically update an only available spec file without any prompts Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command:openapi Issues pertaining to the `openapi`, `validate`, `reduce`, or `swagger` commands enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants