@scalar/openapi-parser 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/configuration/index.d.ts +2 -2
  3. package/dist/configuration/index.js +2 -2
  4. package/dist/configuration/index.js.map +1 -1
  5. package/dist/utils/details.d.ts +1 -2
  6. package/dist/utils/details.d.ts.map +1 -1
  7. package/dist/utils/details.js +12 -9
  8. package/dist/utils/details.js.map +2 -2
  9. package/dist/utils/normalize.d.ts +1 -1
  10. package/dist/utils/normalize.d.ts.map +1 -1
  11. package/dist/utils/normalize.js +16 -11
  12. package/dist/utils/normalize.js.map +2 -2
  13. package/dist/utils/resolve-references.d.ts.map +1 -1
  14. package/dist/utils/resolve-references.js +11 -0
  15. package/dist/utils/resolve-references.js.map +2 -2
  16. package/package.json +2 -2
  17. package/dist/lib/Validator/Validator.test.js +0 -8
  18. package/dist/lib/Validator/Validator.test.js.map +0 -7
  19. package/dist/plugins/fetch-urls/fetch-urls.test.js +0 -50
  20. package/dist/plugins/fetch-urls/fetch-urls.test.js.map +0 -7
  21. package/dist/plugins/read-files/read-files.test.js +0 -20
  22. package/dist/plugins/read-files/read-files.test.js.map +0 -7
  23. package/dist/utils/dereference.test.js +0 -300
  24. package/dist/utils/dereference.test.js.map +0 -7
  25. package/dist/utils/errors.test.js +0 -48
  26. package/dist/utils/errors.test.js.map +0 -7
  27. package/dist/utils/escape-json-pointer.test.js +0 -11
  28. package/dist/utils/escape-json-pointer.test.js.map +0 -7
  29. package/dist/utils/get-entrypoint.test.js +0 -18
  30. package/dist/utils/get-entrypoint.test.js.map +0 -7
  31. package/dist/utils/get-segments-from-path.test.js +0 -13
  32. package/dist/utils/get-segments-from-path.test.js.map +0 -7
  33. package/dist/utils/is-filesystem.test.js +0 -15
  34. package/dist/utils/is-filesystem.test.js.map +0 -7
  35. package/dist/utils/is-object.test.js +0 -23
  36. package/dist/utils/is-object.test.js.map +0 -7
  37. package/dist/utils/load/load.test.js +0 -361
  38. package/dist/utils/load/load.test.js.map +0 -7
  39. package/dist/utils/normalize.test.js +0 -88
  40. package/dist/utils/normalize.test.js.map +0 -7
  41. package/dist/utils/resolve-references.test.js +0 -567
  42. package/dist/utils/resolve-references.test.js.map +0 -7
  43. package/dist/utils/transform/sanitize.test.js +0 -148
  44. package/dist/utils/transform/sanitize.test.js.map +0 -7
  45. package/dist/utils/transform-errors.test.js +0 -17
  46. package/dist/utils/transform-errors.test.js.map +0 -7
  47. package/dist/utils/traverse.test.js +0 -68
  48. package/dist/utils/traverse.test.js.map +0 -7
  49. package/dist/utils/unescape-json-pointer.test.js +0 -19
  50. package/dist/utils/unescape-json-pointer.test.js.map +0 -7
  51. package/dist/utils/upgrade-from-three-to-three-one.test.js +0 -462
  52. package/dist/utils/upgrade-from-three-to-three-one.test.js.map +0 -7
  53. package/dist/utils/upgrade-from-two-to-three.test.js +0 -589
  54. package/dist/utils/upgrade-from-two-to-three.test.js.map +0 -7
  55. package/dist/utils/upgrade.test.js +0 -57
  56. package/dist/utils/upgrade.test.js.map +0 -7
  57. package/dist/utils/validate.test.js +0 -64
  58. package/dist/utils/validate.test.js.map +0 -7
@@ -1,57 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { makeFilesystem } from "./make-filesystem.js";
3
- import { upgrade } from "./upgrade.js";
4
- describe("upgrade", () => {
5
- it("upgrades documents from Swagger 2.0 to OpenAPI 3.1", async () => {
6
- const { specification } = upgrade({
7
- swagger: "2.0",
8
- info: {
9
- title: "Hello World",
10
- version: "1.0.0"
11
- },
12
- paths: {}
13
- });
14
- expect(specification.swagger).toBeUndefined();
15
- expect(specification.openapi).toBe("3.1.1");
16
- });
17
- it("changes the version to from 3.0.0 to 3.1.0", async () => {
18
- const { specification } = upgrade({
19
- openapi: "3.0.0",
20
- info: {
21
- title: "Hello World",
22
- version: "1.0.0"
23
- },
24
- paths: {}
25
- });
26
- expect(specification.openapi).toBe("3.1.1");
27
- });
28
- it("changes the version to 3.0.3 to 3.1.0", async () => {
29
- const { specification } = upgrade({
30
- openapi: "3.0.3",
31
- info: {
32
- title: "Hello World",
33
- version: "1.0.0"
34
- },
35
- paths: {}
36
- });
37
- expect(specification.openapi).toBe("3.1.1");
38
- });
39
- it("works with a filesystem", async () => {
40
- const { specification } = upgrade(
41
- makeFilesystem({
42
- openapi: "3.0.0",
43
- info: {
44
- title: "Hello World",
45
- version: "1.0.0"
46
- },
47
- paths: {}
48
- })
49
- );
50
- expect(specification.openapi).toBe("3.1.1");
51
- });
52
- it("deals with null", async () => {
53
- const { specification } = upgrade(null);
54
- expect(specification).toStrictEqual(null);
55
- });
56
- });
57
- //# sourceMappingURL=upgrade.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/upgrade.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { makeFilesystem } from './make-filesystem'\nimport { upgrade } from './upgrade'\n\ndescribe('upgrade', () => {\n it('upgrades documents from Swagger 2.0 to OpenAPI 3.1', async () => {\n const { specification } = upgrade({\n swagger: '2.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n\n expect(specification.swagger).toBeUndefined()\n expect(specification.openapi).toBe('3.1.1')\n })\n\n it('changes the version to from 3.0.0 to 3.1.0', async () => {\n const { specification } = upgrade({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n\n expect(specification.openapi).toBe('3.1.1')\n })\n\n it('changes the version to 3.0.3 to 3.1.0', async () => {\n const { specification } = upgrade({\n openapi: '3.0.3',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n\n expect(specification.openapi).toBe('3.1.1')\n })\n\n it('works with a filesystem', async () => {\n const { specification } = upgrade(\n makeFilesystem({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n }),\n )\n\n expect(specification.openapi).toBe('3.1.1')\n })\n\n it('deals with null', async () => {\n const { specification } = upgrade(null)\n\n expect(specification).toStrictEqual(null)\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,sBAAsB;AAC/B,SAAS,eAAe;AAExB,SAAS,WAAW,MAAM;AACxB,KAAG,sDAAsD,YAAY;AACnE,UAAM,EAAE,cAAc,IAAI,QAAQ;AAAA,MAChC,SAAS;AAAA,MACT,MAAM;AAAA,QACJ,OAAO;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,OAAO,CAAC;AAAA,IACV,CAAC;AAED,WAAO,cAAc,OAAO,EAAE,cAAc;AAC5C,WAAO,cAAc,OAAO,EAAE,KAAK,OAAO;AAAA,EAC5C,CAAC;AAED,KAAG,8CAA8C,YAAY;AAC3D,UAAM,EAAE,cAAc,IAAI,QAAQ;AAAA,MAChC,SAAS;AAAA,MACT,MAAM;AAAA,QACJ,OAAO;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,OAAO,CAAC;AAAA,IACV,CAAC;AAED,WAAO,cAAc,OAAO,EAAE,KAAK,OAAO;AAAA,EAC5C,CAAC;AAED,KAAG,yCAAyC,YAAY;AACtD,UAAM,EAAE,cAAc,IAAI,QAAQ;AAAA,MAChC,SAAS;AAAA,MACT,MAAM;AAAA,QACJ,OAAO;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,OAAO,CAAC;AAAA,IACV,CAAC;AAED,WAAO,cAAc,OAAO,EAAE,KAAK,OAAO;AAAA,EAC5C,CAAC;AAED,KAAG,2BAA2B,YAAY;AACxC,UAAM,EAAE,cAAc,IAAI;AAAA,MACxB,eAAe;AAAA,QACb,SAAS;AAAA,QACT,MAAM;AAAA,UACJ,OAAO;AAAA,UACP,SAAS;AAAA,QACX;AAAA,QACA,OAAO,CAAC;AAAA,MACV,CAAC;AAAA,IACH;AAEA,WAAO,cAAc,OAAO,EAAE,KAAK,OAAO;AAAA,EAC5C,CAAC;AAED,KAAG,mBAAmB,YAAY;AAChC,UAAM,EAAE,cAAc,IAAI,QAAQ,IAAI;AAEtC,WAAO,aAAa,EAAE,cAAc,IAAI;AAAA,EAC1C,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,64 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { validate } from "./validate.js";
3
- describe("validate", async () => {
4
- it("fails on invalid schema", async () => {
5
- const result = await validate("");
6
- expect(result.valid).toBe(false);
7
- expect(result.errors).toMatchObject([
8
- {
9
- message: "Can\u2019t find supported Swagger/OpenAPI version in specification, version must be a string."
10
- }
11
- ]);
12
- });
13
- it("returns errors for an invalid schema", async () => {
14
- const result = await validate(
15
- `{
16
- "openapi": "3.1.0",
17
- "paths": {}
18
- }`
19
- );
20
- expect(result.valid).toBe(false);
21
- expect(result.errors).toBeTypeOf("object");
22
- expect(Array.isArray(result.errors)).toBe(true);
23
- expect(result.errors.length).toBe(1);
24
- expect(result.errors[0]).toMatchObject({
25
- message: "must have required property 'info'"
26
- });
27
- });
28
- it("returns errors for an invalid specification", async () => {
29
- const result = await validate("pineapples");
30
- expect(result.errors).toHaveLength(1);
31
- expect(result.errors[0].message).toBe(
32
- "Can\u2019t find supported Swagger/OpenAPI version in specification, version must be a string."
33
- );
34
- });
35
- it("works with YAML", async () => {
36
- const result = await validate(`openapi: 3.1.0
37
- info:
38
- title: Hello World
39
- version: 1.0.0
40
- paths: {}
41
- `);
42
- expect(result.schema.info.title).toBe("Hello World");
43
- });
44
- it("doesn\u2019t work with OpenAPI 4.0.0", async () => {
45
- const result = await validate(`{
46
- "openapi": "4.0.0",
47
- "info": {
48
- "title": "Hello World",
49
- "version": "1.0.0"
50
- },
51
- "paths": {}
52
- }`);
53
- expect(result.errors).toHaveLength(1);
54
- expect(result.errors[0].message).toContain("Can\u2019t find supported Swagger/OpenAPI version in specification");
55
- });
56
- it("throws an error", async () => {
57
- expect(async () => {
58
- await validate(void 0, {
59
- throwOnError: true
60
- });
61
- }).rejects.toThrowError("Can\u2019t find JSON, YAML or filename in data");
62
- });
63
- });
64
- //# sourceMappingURL=validate.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/validate.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { validate } from './validate'\n\ndescribe('validate', async () => {\n it('fails on invalid schema', async () => {\n const result = await validate('')\n\n expect(result.valid).toBe(false)\n expect(result.errors).toMatchObject([\n {\n message: 'Can\u2019t find supported Swagger/OpenAPI version in specification, version must be a string.',\n },\n ])\n })\n\n it('returns errors for an invalid schema', async () => {\n const result = await validate(\n `{\n \"openapi\": \"3.1.0\",\n \"paths\": {}\n }`,\n )\n\n expect(result.valid).toBe(false)\n\n expect(result.errors).toBeTypeOf('object')\n expect(Array.isArray(result.errors)).toBe(true)\n expect(result.errors.length).toBe(1)\n expect(result.errors[0]).toMatchObject({\n message: \"must have required property 'info'\",\n })\n })\n\n it('returns errors for an invalid specification', async () => {\n const result = await validate('pineapples')\n\n expect(result.errors).toHaveLength(1)\n expect(result.errors[0].message).toBe(\n 'Can\u2019t find supported Swagger/OpenAPI version in specification, version must be a string.',\n )\n })\n\n it('works with YAML', async () => {\n const result = await validate(`openapi: 3.1.0\ninfo:\n title: Hello World\n version: 1.0.0\npaths: {}\n`)\n\n expect(result.schema.info.title).toBe('Hello World')\n })\n\n it('doesn\u2019t work with OpenAPI 4.0.0', async () => {\n const result = await validate(`{\n \"openapi\": \"4.0.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toHaveLength(1)\n expect(result.errors[0].message).toContain('Can\u2019t find supported Swagger/OpenAPI version in specification')\n })\n\n it('throws an error', async () => {\n expect(async () => {\n await validate(undefined, {\n throwOnError: true,\n })\n }).rejects.toThrowError('Can\u2019t find JSON, YAML or filename in data')\n })\n})\n"],
5
- "mappings": "AAA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