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): auto-detect API definitions #567

Merged

Conversation

kanadgupta
Copy link
Member

@kanadgupta kanadgupta commented Aug 15, 2022

🚥 Fix RM-5059

🧰 Changes

This swaps out our auto-detection of swagger.json, openapi.yml, etc. in the openapi and validate commands for a search functionality that's far more comprehensive.

rdme will now look for any and all JSON or YAML files (including in sub-directories) that contain a top-level openapi or swagger property.1 It will then prompt the user (if in a non-CI environment) if multiple files are found.

Here's what the new workflow looks like:

Screen.Recording.2022-08-16.at.12.10.52.PM.mov

🧬 QA & Testing

Added a whole lotta test coverage which is now passing ✅

Also confirmed that this works when run locally (including in different directories via npm link). I added 2.0/ to the .gitignore file in the oas-examples repo and confirmed that this is what I got when running a linked version of rdme in the repo:

Screen.Recording.2022-08-16.at.12.26.45.PM.mov

Footnotes

  1. rdme will not scan anything in the working directory's .git/ directory, nor any files/directories specified in the .gitignore file (if the file exists).

@kanadgupta kanadgupta added enhancement New feature or request command:openapi Issues pertaining to the `openapi`, `validate`, `reduce`, or `swagger` commands labels Aug 15, 2022
After struggling for hours with `enquirer` and trying to get a single test to run properly, I caved and went with `prompts`. I'm completely blown away by how simple it was to write a test and I'm so mad about it lol 😭

Tagging a few PRs below that I tried to reference when writing `enquirer` tests:
enquirer/enquirer#234
enquirer/enquirer#284
I think these docs should be in third person when describing what the tool does (e.g. "rdme does this" vs. "we do this"). I think using first-person grammar is fine when describing our recommendations.

Also using the GitHub callout syntax, see: https://github.com/orgs/community/discussions/16925
@kanadgupta kanadgupta marked this pull request as ready for review August 16, 2022 17:27
@kanadgupta kanadgupta requested review from a team, erunion, Dashron, domharrington and darrenyong and removed request for a team August 16, 2022 17:28
src/lib/prepareOas.ts Outdated Show resolved Hide resolved
src/lib/prepareOas.ts Outdated Show resolved Hide resolved
src/lib/prepareOas.ts Outdated Show resolved Hide resolved
src/lib/prepareOas.ts Show resolved Hide resolved
src/lib/readdirRecursive.ts Outdated Show resolved Hide resolved
kanadgupta and others added 2 commits August 16, 2022 14:17
We're no longer creating this file in tests, so no need to ignore it.
Co-Authored-By: Jon Ursenbach <[email protected]>
@kanadgupta kanadgupta requested a review from erunion August 16, 2022 21:31
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.

hell yeah

src/lib/prepareOas.ts Outdated Show resolved Hide resolved
Co-authored-by: Jon Ursenbach <[email protected]>
@kanadgupta kanadgupta merged commit 0e7759a into main Aug 16, 2022
@kanadgupta kanadgupta deleted the kanad/rm-5059-expand-openapi-file-search-functionality branch August 16, 2022 21:41
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.

2 participants