Skip to content

Commit

Permalink
feat: upgrading our openapi parser to support OAS 3.1.1 and 3.0.4 (#927)
Browse files Browse the repository at this point in the history
Resolves #923
  • Loading branch information
erunion authored Jan 24, 2025
1 parent 319ae00 commit 491d63a
Show file tree
Hide file tree
Showing 10 changed files with 398 additions and 344 deletions.
687 changes: 360 additions & 327 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
],
"devDependencies": {
"@readme/eslint-config": "^14.0.0",
"@vitest/coverage-v8": "^2.1.3",
"@vitest/coverage-v8": "^3.0.4",
"alex": "^11.0.1",
"eslint": "^8.57.0",
"lerna": "^8.1.2",
"prettier": "^3.2.5",
"vitest": "^2.1.3"
"vitest": "^3.0.4"
},
"prettier": "@readme/eslint-config/prettier"
}
6 changes: 3 additions & 3 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,10 +75,10 @@
"@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"
"vitest": "^3.0.4"
},
"prettier": "@readme/eslint-config/prettier"
}
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
2 changes: 1 addition & 1 deletion packages/oas-to-har/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"tsup": "^8.0.2",
"type-fest": "^4.18.3",
"typescript": "^5.2.2",
"vitest": "^2.1.3"
"vitest": "^3.0.4"
},
"prettier": "@readme/eslint-config/prettier"
}
2 changes: 1 addition & 1 deletion packages/oas-to-snippet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"tsup": "^8.0.2",
"type-fest": "^4.18.3",
"typescript": "^5.2.2",
"vitest": "^2.1.3"
"vitest": "^3.0.4"
},
"prettier": "@readme/eslint-config/prettier"
}
4 changes: 2 additions & 2 deletions packages/oas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@
},
"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",
"tsup": "^8.0.2",
"typescript": "^5.4.4",
"vitest": "^2.1.3"
"vitest": "^3.0.4"
},
"prettier": "@readme/eslint-config/prettier"
}
14 changes: 14 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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',
},
workspace: ['packages/*'],
},
});
4 changes: 0 additions & 4 deletions vitest.workspace.ts

This file was deleted.

0 comments on commit 491d63a

Please sign in to comment.