Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into oleh/openapi-adding-comman…
Browse files Browse the repository at this point in the history
…d-to-solve-circularity-and-recursiveness
  • Loading branch information
Oleh Shumov committed Dec 6, 2024
2 parents 9c037c9 + 5583d77 commit da5b0ad
Show file tree
Hide file tree
Showing 45 changed files with 479 additions and 122 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,35 @@ jobs:
run: npm ci && npm run build:gha
working-directory: rdme-repo

- name: Run `openapi:validate` command
- name: Run `openapi validate` command
uses: ./rdme-repo/
with:
rdme: openapi validate oas-examples-repo/3.1/json/petstore.json

- name: Run `openapi validate` command (legacy topic separator)
uses: ./rdme-repo/
with:
rdme: openapi:validate oas-examples-repo/3.1/json/petstore.json

- name: Run `openapi:validate` with filename in quotes
- name: Run `openapi validate` with filename in quotes
uses: ./rdme-repo/
with:
rdme: openapi validate "oas-examples-repo/3.1/json/petstore.json"

- name: Run `openapi validate` on an invalid file
uses: ./rdme-repo/
id: openapi-validate-fail
continue-on-error: true
with:
rdme: openapi:validate "oas-examples-repo/3.1/json/petstore.json"
rdme: openapi validate rdme-repo/__tests__/__fixtures__/invalid-oas.json

- name: Assert that previous validation step failed
if: ${{ steps.openapi-validate-fail.outcome == 'failure' }}
run: echo "The validation in the previous step failed as expected."

- name: Throw error if previous validation step did not fail
if: ${{ steps.openapi-validate-fail.outcome == 'success' }}
run: echo "::error::Expected validation in previous step to fail" && exit 1

# Docs: https://rdme-test.readme.io
- name: Run `openapi` command
Expand Down
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
# [9.0.0-next.35](https://github.com/readmeio/rdme/compare/v9.0.0-next.34...v9.0.0-next.35) (2024-12-05)


* feat!: deprecation notices for non-readme-refactored commands ([#1099](https://github.com/readmeio/rdme/issues/1099)) ([732e32b](https://github.com/readmeio/rdme/commit/732e32bbccd1deb4a1f44d9ce0d7befc234e7c40))


### BREAKING CHANGES

* deprecates commands that are not supported in ReadMe
Refactored. For more information, please visit our migration guide:
https://github.com/readmeio/rdme/tree/v9/documentation/migration-guide.md

## 🧬 QA & Testing

Does the copy in these deprecation warnings make sense to you? Note that
the links will be broken for now since we haven't tagged a proper v9
release yet, but that will be fixed once this release is out!

# [9.0.0-next.34](https://github.com/readmeio/rdme/compare/v9.0.0-next.33...v9.0.0-next.34) (2024-12-05)


* feat!: switch topic separator to space ([#1100](https://github.com/readmeio/rdme/issues/1100)) ([13eb8ab](https://github.com/readmeio/rdme/commit/13eb8abfd29d678e95c9e7ef52ccc22575386519))


### BREAKING CHANGES

* the topic separator (i.e., what separates a command
from its subcommand) has changed from a colon to a space by default. For
example, `rdme openapi:validate` is now `rdme openapi validate`. The
colon topic separator will continue to be supported so there is no need
to change any existing commands, but all documentation and help screens
will reflect the space topic separator.

## 🧬 QA & Testing

Do tests still pass?

# [9.0.0-next.33](https://github.com/readmeio/rdme/compare/v9.0.0-next.32...v9.0.0-next.33) (2024-12-02)


Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ To run test commands, swap out `rdme` for `bin/dev.js`. For example:

```sh
# if the production command you're testing looks like this...
rdme openapi:validate __tests__/__fixtures__/ref-oas/petstore.json
rdme openapi validate __tests__/__fixtures__/ref-oas/petstore.json

# ... your local test command will look like this:
bin/dev.js openapi:validate __tests__/__fixtures__/ref-oas/petstore.json
bin/dev.js openapi validate __tests__/__fixtures__/ref-oas/petstore.json
```

The `bin/dev.js` file has a few features that are useful for local development:
Expand All @@ -27,7 +27,7 @@ The `bin/dev.js` file has a few features that are useful for local development:

```sh
npm run build
bin/run.js openapi:validate __tests__/__fixtures__/ref-oas/petstore.json
bin/run.js openapi validate __tests__/__fixtures__/ref-oas/petstore.json
```

Your changes to the command code may make changes to [the command reference documents](./documentation/commands) — it is up to you whether you include those changes in your PR or if you let the release process take care of it. More information on that can be found in [`MAINTAINERS.md`](./MAINTAINERS.md).
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ npm install rdme --save-dev
Once installed in your project, you can use the `npx` prefix (which is included if you have `npm` installed) to run your CLI commands locally. For example:

```sh
npx rdme openapi:validate [file]
npx rdme openapi validate [file]
```

To ensure you're getting the latest features and security updates, we recommend using a tool like [Dependabot](https://docs.github.com/code-security/dependabot/dependabot-version-updates/about-dependabot-version-updates) to keep `rdme` (and your other dependencies) up-to-date.
Expand Down Expand Up @@ -153,7 +153,7 @@ $ npm install -g rdme
$ rdme COMMAND
running command...
$ rdme (--version)
rdme/9.0.0-next.33 linux-x64 node-v20.18.1
rdme/9.0.0-next.35 linux-x64 node-v20.18.1
$ rdme --help [COMMAND]
USAGE
$ rdme COMMAND
Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/categories/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { runCommandAndReturnResult } from '../../helpers/oclif.js';
const key = 'API_KEY';
const version = '1.0.0';

describe('rdme categories:create', () => {
describe('rdme categories create', () => {
let run: (args?: string[]) => Promise<string>;

beforeAll(() => {
Expand Down
6 changes: 3 additions & 3 deletions __tests__/commands/docs/prune.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const fixturesBaseDir = '__fixtures__/docs';
const key = 'API_KEY';
const version = '1.0.0';

describe('rdme docs:prune', () => {
describe('rdme docs prune', () => {
const folder = `./__tests__/${fixturesBaseDir}/delete-docs`;
let run: (args?: string[]) => Promise<string>;

Expand Down Expand Up @@ -162,10 +162,10 @@ describe('rdme docs:prune', () => {
versionMock.done();
});

describe('rdme guides:prune', () => {
describe('rdme guides prune', () => {
it('should error if no folder provided', async () => {
return expect(
(await runCommandWithHooks(['guides:prune', '--key', key, '--version', version])).error.message,
(await runCommandWithHooks(['guides', 'prune', '--key', key, '--version', version])).error.message,
).toContain('Missing 1 required arg:\nfolder');
});
});
Expand Down
16 changes: 8 additions & 8 deletions __tests__/commands/openapi/__snapshots__/inspect.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`rdme openapi:inspect > feature reports > should generate a report for '@readme/oas-examples/3.0/json/readme.…' (w/ [ 'polymorphism' ]) 1`] = `
exports[`rdme openapi inspect > feature reports > should generate a report for '@readme/oas-examples/3.0/json/readme.…' (w/ [ 'polymorphism' ]) 1`] = `
"
polymorphism:
· #/components/responses/authForbidden/content/application~1json/schema
Expand Down Expand Up @@ -50,7 +50,7 @@ polymorphism:
· #/paths/~1version/post/responses/400/content/application~1json/schema"
`;

exports[`rdme openapi:inspect > feature reports > should generate a report for '@readme/oas-examples/3.0/json/readme-…' (w/ [ 'readme' ]) 1`] = `
exports[`rdme openapi inspect > feature reports > should generate a report for '@readme/oas-examples/3.0/json/readme-…' (w/ [ 'readme' ]) 1`] = `
"
x-default: You do not use this.
x-readme.code-samples:
Expand All @@ -76,7 +76,7 @@ x-readme.samples-languages:
· swift"
`;

exports[`rdme openapi:inspect > feature reports > should generate a report for '@readme/oas-examples/3.0/json/schema-…' (w/ [ 'additionalProperties', …(1) ]) 1`] = `
exports[`rdme openapi inspect > feature reports > should generate a report for '@readme/oas-examples/3.0/json/schema-…' (w/ [ 'additionalProperties', …(1) ]) 1`] = `
"
additionalProperties:
· #/components/schemas/BodyPart/properties/headers/additionalProperties
Expand All @@ -97,7 +97,7 @@ circularRefs:
· #/components/schemas/ZoneOffset/properties/rules"
`;

exports[`rdme openapi:inspect > feature reports > should generate a report for '@readme/oas-examples/3.0/json/schema-…' (w/ [ 'additionalProperties', …(2) ]) 1`] = `
exports[`rdme openapi inspect > feature reports > should generate a report for '@readme/oas-examples/3.0/json/schema-…' (w/ [ 'additionalProperties', …(2) ]) 1`] = `
"
additionalProperties:
· #/components/schemas/BodyPart/properties/headers/additionalProperties
Expand Down Expand Up @@ -125,7 +125,7 @@ x-readme.proxy-enabled: You do not use this.
x-readme.samples-languages: You do not use this."
`;

exports[`rdme openapi:inspect > feature reports > should generate a report for '@readme/oas-examples/3.0/json/schema-…' (w/ [ 'circularRefs', 'readme' ]) 1`] = `
exports[`rdme openapi inspect > feature reports > should generate a report for '@readme/oas-examples/3.0/json/schema-…' (w/ [ 'circularRefs', 'readme' ]) 1`] = `
"
circularRefs:
· #/components/schemas/MultiPart/properties/parent
Expand All @@ -139,7 +139,7 @@ x-readme.proxy-enabled: You do not use this.
x-readme.samples-languages: You do not use this."
`;

exports[`rdme openapi:inspect > full reports > should generate a report for @readme/oas-examples/3.0/json/petstore.json 1`] = `
exports[`rdme openapi inspect > full reports > should generate a report for @readme/oas-examples/3.0/json/petstore.json 1`] = `
"Here are some interesting things we found in your API definition. 🕵️
· You are using 4 Media Types throughout your API: application/json, application/x-www-form-urlencoded, application/xml, and multipart/form-data
Expand Down Expand Up @@ -249,7 +249,7 @@ ReadMe-Specific Features and Extensions
"
`;

exports[`rdme openapi:inspect > full reports > should generate a report for @readme/oas-examples/3.0/json/readme.json 1`] = `
exports[`rdme openapi inspect > full reports > should generate a report for @readme/oas-examples/3.0/json/readme.json 1`] = `
"Here are some interesting things we found in your API definition. 🕵️
· You are using 2 Media Types throughout your API: application/json and multipart/form-data
Expand Down Expand Up @@ -359,7 +359,7 @@ ReadMe-Specific Features and Extensions
"
`;

exports[`rdme openapi:inspect > full reports > should generate a report for @readme/oas-examples/3.0/json/readme-extensions.json 1`] = `
exports[`rdme openapi inspect > full reports > should generate a report for @readme/oas-examples/3.0/json/readme-extensions.json 1`] = `
"Here are some interesting things we found in your API definition. 🕵️
· You are using a single Media Type throughout your API: application/json
Expand Down
40 changes: 20 additions & 20 deletions __tests__/commands/openapi/__snapshots__/validate.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`rdme openapi:validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via opt (github flag enabled) 1`] = `
exports[`rdme openapi validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via opt (github flag enabled) 1`] = `
"
Your GitHub Actions workflow file has been created! ✨
Expand All @@ -10,7 +10,7 @@ Almost done! Push your newly created file (.github/workflows/validate-test-opt-s
"
`;

exports[`rdme openapi:validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via opt (github flag enabled) 2`] = `
exports[`rdme openapi validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via opt (github flag enabled) 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉
Expand All @@ -30,14 +30,14 @@ jobs:
- name: Check out repo 📚
uses: actions/checkout@v4
- name: Run \`openapi:validate\` command 🚀
- name: Run \`openapi validate\` command 🚀
uses: readmeio/rdme@v7
with:
rdme: openapi:validate __tests__/__fixtures__/petstore-simple-weird-version.json
rdme: openapi validate __tests__/__fixtures__/petstore-simple-weird-version.json
"
`;

exports[`rdme openapi:validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via opt (including workingDirectory) 1`] = `
exports[`rdme openapi validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via opt (including workingDirectory) 1`] = `
"
Your GitHub Actions workflow file has been created! ✨
Expand All @@ -47,7 +47,7 @@ Almost done! Push your newly created file (.github/workflows/validate-test-opt-s
"
`;

exports[`rdme openapi:validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via opt (including workingDirectory) 2`] = `
exports[`rdme openapi validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via opt (including workingDirectory) 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉
Expand All @@ -67,14 +67,14 @@ jobs:
- name: Check out repo 📚
uses: actions/checkout@v4
- name: Run \`openapi:validate\` command 🚀
- name: Run \`openapi validate\` command 🚀
uses: readmeio/rdme@v7
with:
rdme: openapi:validate petstore.json --workingDirectory=./__tests__/__fixtures__/relative-ref-oas
rdme: openapi validate petstore.json --workingDirectory=./__tests__/__fixtures__/relative-ref-oas
"
`;

exports[`rdme openapi:validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via opt 1`] = `
exports[`rdme openapi validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via opt 1`] = `
"
Your GitHub Actions workflow file has been created! ✨
Expand All @@ -84,7 +84,7 @@ Almost done! Push your newly created file (.github/workflows/validate-test-opt-s
"
`;

exports[`rdme openapi:validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via opt 2`] = `
exports[`rdme openapi validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via opt 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉
Expand All @@ -104,14 +104,14 @@ jobs:
- name: Check out repo 📚
uses: actions/checkout@v4
- name: Run \`openapi:validate\` command 🚀
- name: Run \`openapi validate\` command 🚀
uses: readmeio/rdme@v7
with:
rdme: openapi:validate __tests__/__fixtures__/petstore-simple-weird-version.json
rdme: openapi validate __tests__/__fixtures__/petstore-simple-weird-version.json
"
`;

exports[`rdme openapi:validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via prompts 1`] = `
exports[`rdme openapi validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via prompts 1`] = `
"
Your GitHub Actions workflow file has been created! ✨
Expand All @@ -121,7 +121,7 @@ Almost done! Push your newly created file (.github/workflows/validate-test-file.
"
`;

exports[`rdme openapi:validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via prompts 2`] = `
exports[`rdme openapi validate > GHA onboarding E2E tests > should create GHA workflow if user passes in spec via prompts 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉
Expand All @@ -141,14 +141,14 @@ jobs:
- name: Check out repo 📚
uses: actions/checkout@v4
- name: Run \`openapi:validate\` command 🚀
- name: Run \`openapi validate\` command 🚀
uses: readmeio/rdme@v7
with:
rdme: openapi:validate __tests__/__fixtures__/petstore-simple-weird-version.json
rdme: openapi validate __tests__/__fixtures__/petstore-simple-weird-version.json
"
`;

exports[`rdme openapi:validate > error handling > should throw an error if an invalid API definition has many errors 1`] = `
exports[`rdme openapi validate > error handling > should throw an error if an invalid API definition has many errors 1`] = `
[SyntaxError: OpenAPI schema validation failed.
REQUIRED must have required property 'url'
Expand All @@ -172,9 +172,9 @@ ADDITIONAL PROPERTY must NOT have additional properties
29 | "summary": "Finds Pets by status",]
`;
exports[`rdme openapi:validate > error handling > should throw an error if an invalid OpenAPI 3.0 definition is supplied 1`] = `[MissingPointerError: Token "Error" does not exist.]`;
exports[`rdme openapi validate > error handling > should throw an error if an invalid OpenAPI 3.0 definition is supplied 1`] = `[MissingPointerError: Token "Error" does not exist.]`;
exports[`rdme openapi:validate > error handling > should throw an error if an invalid OpenAPI 3.1 definition is supplied 1`] = `
exports[`rdme openapi validate > error handling > should throw an error if an invalid OpenAPI 3.1 definition is supplied 1`] = `
[SyntaxError: OpenAPI schema validation failed.
REQUIRED must have required property 'name'
Expand All @@ -188,7 +188,7 @@ REQUIRED must have required property 'name'
29 | }]
`;
exports[`rdme openapi:validate > error handling > should throw an error if an invalid Swagger definition is supplied 1`] = `
exports[`rdme openapi validate > error handling > should throw an error if an invalid Swagger definition is supplied 1`] = `
[SyntaxError: Swagger schema validation failed.
ADDITIONAL PROPERTY must NOT have additional properties
Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/openapi/convert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { runCommandAndReturnResult } from '../../helpers/oclif.js';

const successfulConversion = () => 'Your API definition has been converted and bundled and saved to output.json!';

describe('rdme openapi:convert', () => {
describe('rdme openapi convert', () => {
let run: (args?: string[]) => Promise<string>;
let testWorkingDir: string;

Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/openapi/inspect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { describe, it, expect, beforeAll } from 'vitest';
import Command from '../../../src/commands/openapi/inspect.js';
import { runCommandAndReturnResult } from '../../helpers/oclif.js';

describe('rdme openapi:inspect', () => {
describe('rdme openapi inspect', () => {
let run: (args?: string[]) => Promise<unknown>;

beforeAll(() => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/openapi/reduce.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const successfulReduction = () => 'Your reduced API definition has been saved to
let consoleInfoSpy: MockInstance;
const getCommandOutput = () => consoleInfoSpy.mock.calls.join('\n\n');

describe('rdme openapi:reduce', () => {
describe('rdme openapi reduce', () => {
let run: (args?: string[]) => Promise<unknown>;
let testWorkingDir: string;

Expand Down
Loading

0 comments on commit da5b0ad

Please sign in to comment.