Skip to content

Commit

Permalink
feat: upgrading our openapi parser to support OAS 3.1.1 and 3.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion committed Jan 24, 2025
1 parent 319ae00 commit 4d94445
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 56 deletions.
69 changes: 20 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/oas-normalize/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"license": "MIT",
"dependencies": {
"@readme/openapi-parser": "^2.6.0",
"@readme/openapi-parser": "^2.7.0",
"@readme/postman-to-openapi": "^4.1.0",
"js-yaml": "^4.1.0",
"openapi-types": "^12.1.3",
Expand All @@ -75,7 +75,7 @@
"@types/js-yaml": "^4.0.9",
"@types/swagger2openapi": "^7.0.4",
"eslint": "^8.57.0",
"nock": "^14.0.0-beta.12",
"nock": "^14.0.0",
"tsup": "^8.0.2",
"typescript": "^5.1.6",
"vitest": "^2.1.3"
Expand Down
14 changes: 14 additions & 0 deletions packages/oas-normalize/test/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14512,6 +14512,20 @@ exports[`#convert > Swagger 2.0 support > should validate a YAML path as expecte
}
`;

exports[`#validate > should colorize errors when \`opts.colorizeErrors\` is present 1`] = `
[SyntaxError: OpenAPI schema validation failed.

REQUIRED must have required property 'name'

24 | "components": {
25 | "securitySchemes": {
> 26 | "tlsAuth": {
| ^ ☹️ name is missing here!
27 | "type": "mutualTLS"
28 | }
29 | }]
`;

exports[`#validate > should error out, and show all errors, when a definition has lots of problems 1`] = `
"OpenAPI schema validation failed.

Expand Down
5 changes: 1 addition & 4 deletions packages/oas-normalize/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,7 @@ describe('#validate', () => {
await expect(o.validate()).rejects.toStrictEqual(new Error('No file contents found.'));
});

// Skipping because the `chalk` dependency of `better-ajv-errors` within `openapi-parser` has
// issues in CI. Test works fine locally though!
// eslint-disable-next-line vitest/no-disabled-tests
it.skip('should colorize errors when `opts.colorizeErrors` is present', async () => {
it('should colorize errors when `opts.colorizeErrors` is present', async () => {
const o = new OASNormalize(require.resolve('./__fixtures__/invalid/openapi-3.1.json'), {
colorizeErrors: true,
enablePaths: true,
Expand Down
13 changes: 13 additions & 0 deletions packages/oas-normalize/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
env: {
// Vitest strips colors from content by default and `chalk` has troubles with color detection
// in CI.
// https://github.com/chalk/supports-color/issues/106
FORCE_COLOR: '1',
},
},
});
2 changes: 1 addition & 1 deletion packages/oas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
},
"devDependencies": {
"@readme/oas-examples": "^5.13.0",
"@readme/openapi-parser": "^2.6.0",
"@readme/openapi-parser": "^2.7.0",
"@types/json-schema-merge-allof": "^0.6.5",
"@types/memoizee": "^0.4.11",
"@types/node": "^22.7.6",
Expand Down

0 comments on commit 4d94445

Please sign in to comment.