@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,300 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { dereference } from "./dereference.js";
3
- describe("dereference", async () => {
4
- it("dereferences an OpenAPI 3.1.0 file", async () => {
5
- const result = await dereference(`{
6
- "openapi": "3.1.0",
7
- "info": {
8
- "title": "Hello World",
9
- "version": "1.0.0"
10
- },
11
- "paths": {}
12
- }`);
13
- expect(result.errors).toStrictEqual([]);
14
- expect(result.schema.info.title).toBe("Hello World");
15
- });
16
- it("dereferences an OpenAPI 3.0.0 file", async () => {
17
- const result = await dereference(`{
18
- "openapi": "3.0.0",
19
- "info": {
20
- "title": "Hello World",
21
- "version": "1.0.0"
22
- },
23
- "paths": {}
24
- }`);
25
- expect(result.errors).toStrictEqual([]);
26
- expect(result.schema.info.title).toBe("Hello World");
27
- });
28
- it("dereferences an Swagger 2.0 file", async () => {
29
- const result = await dereference(`{
30
- "swagger": "2.0",
31
- "info": {
32
- "title": "Hello World",
33
- "version": "1.0.0"
34
- },
35
- "paths": {}
36
- }`);
37
- expect(result.errors).toStrictEqual([]);
38
- expect(result.schema.info.title).toBe("Hello World");
39
- });
40
- it("returns version 3.1", async () => {
41
- const result = await dereference(`{
42
- "openapi": "3.1.0",
43
- "info": {
44
- "title": "Hello World",
45
- "version": "1.0.0"
46
- },
47
- "paths": {}
48
- }`);
49
- expect(result.errors).toStrictEqual([]);
50
- expect(result.version).toBe("3.1");
51
- });
52
- it("returns version 3.0", async () => {
53
- const result = await dereference(`{
54
- "openapi": "3.0.0",
55
- "info": {
56
- "title": "Hello World",
57
- "version": "1.0.0"
58
- },
59
- "paths": {}
60
- }`);
61
- expect(result.errors).toStrictEqual([]);
62
- expect(result.version).toBe("3.0");
63
- });
64
- it("returns version 2.0", async () => {
65
- const result = await dereference(`{
66
- "swagger": "2.0",
67
- "info": {
68
- "title": "Hello World",
69
- "version": "1.0.0"
70
- },
71
- "paths": {}
72
- }`);
73
- expect(result.errors).toStrictEqual([]);
74
- expect(result.version).toBe("2.0");
75
- });
76
- it("doesn\u2019t return version 4.0", async () => {
77
- const result = await dereference(`{
78
- "openapi": "4.0",
79
- "info": {
80
- "title": "Hello World",
81
- "version": "1.0.0"
82
- },
83
- "paths": {}
84
- }`);
85
- expect(result.version).toBe(void 0);
86
- });
87
- it("dereferences a simple reference", async () => {
88
- const openapi = {
89
- openapi: "3.1.0",
90
- info: {
91
- title: "Hello World",
92
- version: "1.0.0"
93
- },
94
- paths: {
95
- "/test": {
96
- get: {
97
- responses: {
98
- "200": {
99
- // TODO: This is valid in @apidevtools/swagger, but not with our implementation
100
- description: "foobar",
101
- content: {
102
- "application/json": {
103
- schema: {
104
- $ref: "#/components/schemas/Test"
105
- }
106
- }
107
- }
108
- }
109
- }
110
- }
111
- }
112
- },
113
- components: {
114
- schemas: {
115
- Test: {
116
- type: "object",
117
- properties: {
118
- id: {
119
- type: "string"
120
- }
121
- }
122
- }
123
- }
124
- }
125
- };
126
- const result = await dereference(openapi);
127
- expect(result.errors).toStrictEqual([]);
128
- expect(result.specification.paths["/test"].get.responses["200"].content["application/json"].schema).toEqual({
129
- $ref: "#/components/schemas/Test"
130
- });
131
- expect(result.schema.paths["/test"].get.responses["200"].content["application/json"].schema).toEqual({
132
- type: "object",
133
- properties: {
134
- id: {
135
- type: "string"
136
- }
137
- }
138
- });
139
- });
140
- it("throws an error", async () => {
141
- expect(async () => {
142
- await dereference(
143
- {
144
- openapi: "3.1.0",
145
- info: {},
146
- paths: {
147
- "/foobar": {
148
- post: {
149
- requestBody: {
150
- $ref: "#/components/requestBodies/DoesNotExist"
151
- }
152
- }
153
- }
154
- }
155
- },
156
- {
157
- throwOnError: true
158
- }
159
- );
160
- }).rejects.toThrowError("Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist");
161
- });
162
- it("resolves external file references", async () => {
163
- const filesystem = [
164
- {
165
- isEntrypoint: true,
166
- specification: {
167
- openapi: "3.1.0",
168
- info: {
169
- title: "File Reference",
170
- version: "1.0.0"
171
- },
172
- paths: {},
173
- components: {
174
- schemas: {
175
- ExternalSchema: {
176
- $ref: "valid.yaml#/components/schemas/ExampleSchema"
177
- }
178
- }
179
- }
180
- },
181
- filename: "file-reference.yaml",
182
- dir: "./",
183
- references: ["valid.yaml"]
184
- },
185
- {
186
- isEntrypoint: false,
187
- specification: {
188
- openapi: "3.1.0",
189
- info: {
190
- title: "Hello World",
191
- version: "1.0.0"
192
- },
193
- paths: {},
194
- components: {
195
- schemas: {
196
- ExampleSchema: {
197
- type: "object",
198
- properties: {
199
- id: {
200
- type: "integer",
201
- description: "Unique identifier for the example"
202
- },
203
- name: {
204
- type: "string",
205
- description: "Name of the example"
206
- },
207
- description: {
208
- type: "string",
209
- description: "Detailed description of the example"
210
- }
211
- },
212
- required: ["id", "name"]
213
- }
214
- }
215
- }
216
- },
217
- filename: "valid.yaml",
218
- dir: "./",
219
- references: []
220
- }
221
- ];
222
- const result = await dereference(filesystem);
223
- expect(result.errors).toStrictEqual([]);
224
- expect(result.schema.components.schemas.ExternalSchema).toEqual({
225
- type: "object",
226
- properties: {
227
- id: {
228
- type: "integer",
229
- description: "Unique identifier for the example"
230
- },
231
- name: {
232
- type: "string",
233
- description: "Name of the example"
234
- },
235
- description: {
236
- type: "string",
237
- description: "Detailed description of the example"
238
- }
239
- },
240
- required: ["id", "name"]
241
- });
242
- });
243
- it("calls onDereference when resolving references", async () => {
244
- const openapi = {
245
- openapi: "3.1.0",
246
- info: {
247
- title: "Hello World",
248
- version: "1.0.0"
249
- },
250
- paths: {
251
- "/test": {
252
- get: {
253
- responses: {
254
- "200": {
255
- description: "foobar",
256
- content: {
257
- "application/json": {
258
- schema: {
259
- $ref: "#/components/schemas/Test"
260
- }
261
- }
262
- }
263
- }
264
- }
265
- }
266
- }
267
- },
268
- components: {
269
- schemas: {
270
- Test: {
271
- type: "object",
272
- properties: {
273
- id: {
274
- type: "string"
275
- }
276
- }
277
- }
278
- }
279
- }
280
- };
281
- const dereferencedSchemas = [];
282
- const result = await dereference(openapi, {
283
- onDereference: ({ schema, ref }) => {
284
- expect(schema).toEqual({
285
- type: "object",
286
- properties: {
287
- id: {
288
- type: "string"
289
- }
290
- }
291
- });
292
- expect(ref).toEqual("#/components/schemas/Test");
293
- dereferencedSchemas.push({ schema, ref });
294
- }
295
- });
296
- expect(result.errors).toStrictEqual([]);
297
- expect(dereferencedSchemas).toHaveLength(1);
298
- });
299
- });
300
- //# sourceMappingURL=dereference.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/dereference.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { dereference } from './dereference'\n\ndescribe('dereference', async () => {\n it('dereferences an OpenAPI 3.1.0 file', async () => {\n const result = await dereference(`{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toStrictEqual([])\n expect(result.schema.info.title).toBe('Hello World')\n })\n\n it('dereferences an OpenAPI 3.0.0 file', async () => {\n const result = await dereference(`{\n \"openapi\": \"3.0.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toStrictEqual([])\n expect(result.schema.info.title).toBe('Hello World')\n })\n\n it('dereferences an Swagger 2.0 file', async () => {\n const result = await dereference(`{\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toStrictEqual([])\n expect(result.schema.info.title).toBe('Hello World')\n })\n\n it('returns version 3.1', async () => {\n const result = await dereference(`{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toStrictEqual([])\n expect(result.version).toBe('3.1')\n })\n\n it('returns version 3.0', async () => {\n const result = await dereference(`{\n \"openapi\": \"3.0.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toStrictEqual([])\n expect(result.version).toBe('3.0')\n })\n\n it('returns version 2.0', async () => {\n const result = await dereference(`{\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.errors).toStrictEqual([])\n expect(result.version).toBe('2.0')\n })\n\n it('doesn\u2019t return version 4.0', async () => {\n const result = await dereference(`{\n \"openapi\": \"4.0\",\n \"info\": {\n \"title\": \"Hello World\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {}\n }`)\n\n expect(result.version).toBe(undefined)\n })\n\n it('dereferences a simple reference', async () => {\n const openapi = {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/test': {\n get: {\n responses: {\n '200': {\n // TODO: This is valid in @apidevtools/swagger, but not with our implementation\n description: 'foobar',\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/Test',\n },\n },\n },\n },\n },\n },\n },\n },\n components: {\n schemas: {\n Test: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n },\n },\n },\n },\n },\n }\n\n const result = await dereference(openapi)\n\n expect(result.errors).toStrictEqual([])\n\n // Original\n expect(result.specification.paths['/test'].get.responses['200'].content['application/json'].schema).toEqual({\n $ref: '#/components/schemas/Test',\n })\n\n // Resolved references\n expect(result.schema.paths['/test'].get.responses['200'].content['application/json'].schema).toEqual({\n type: 'object',\n properties: {\n id: {\n type: 'string',\n },\n },\n })\n })\n\n it('throws an error', async () => {\n expect(async () => {\n await dereference(\n {\n openapi: '3.1.0',\n info: {},\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: '#/components/requestBodies/DoesNotExist',\n },\n },\n },\n },\n },\n {\n throwOnError: true,\n },\n )\n }).rejects.toThrowError('Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist')\n })\n\n it('resolves external file references', async () => {\n const filesystem = [\n {\n isEntrypoint: true,\n specification: {\n openapi: '3.1.0',\n info: {\n title: 'File Reference',\n version: '1.0.0',\n },\n paths: {},\n components: {\n schemas: {\n ExternalSchema: {\n $ref: 'valid.yaml#/components/schemas/ExampleSchema',\n },\n },\n },\n },\n filename: 'file-reference.yaml',\n dir: './',\n references: ['valid.yaml'],\n },\n {\n isEntrypoint: false,\n specification: {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n components: {\n schemas: {\n ExampleSchema: {\n type: 'object',\n properties: {\n id: {\n type: 'integer',\n description: 'Unique identifier for the example',\n },\n name: {\n type: 'string',\n description: 'Name of the example',\n },\n description: {\n type: 'string',\n description: 'Detailed description of the example',\n },\n },\n required: ['id', 'name'],\n },\n },\n },\n },\n filename: 'valid.yaml',\n dir: './',\n references: [],\n },\n ]\n\n const result = await dereference(filesystem)\n\n expect(result.errors).toStrictEqual([])\n\n // Check if the external reference was resolved\n expect(result.schema.components.schemas.ExternalSchema).toEqual({\n type: 'object',\n properties: {\n id: {\n type: 'integer',\n description: 'Unique identifier for the example',\n },\n name: {\n type: 'string',\n description: 'Name of the example',\n },\n description: {\n type: 'string',\n description: 'Detailed description of the example',\n },\n },\n required: ['id', 'name'],\n })\n })\n\n it('calls onDereference when resolving references', async () => {\n const openapi = {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/test': {\n get: {\n responses: {\n '200': {\n description: 'foobar',\n content: {\n 'application/json': {\n schema: {\n $ref: '#/components/schemas/Test',\n },\n },\n },\n },\n },\n },\n },\n },\n components: {\n schemas: {\n Test: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n },\n },\n },\n },\n },\n }\n\n const dereferencedSchemas: Array<{ schema: any; ref: string }> = []\n\n const result = await dereference(openapi, {\n onDereference: ({ schema, ref }) => {\n expect(schema).toEqual({\n type: 'object',\n properties: {\n id: {\n type: 'string',\n },\n },\n })\n\n expect(ref).toEqual('#/components/schemas/Test')\n\n dereferencedSchemas.push({ schema, ref })\n },\n })\n\n expect(result.errors).toStrictEqual([])\n expect(dereferencedSchemas).toHaveLength(1)\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,mBAAmB;AAE5B,SAAS,eAAe,YAAY;AAClC,KAAG,sCAAsC,YAAY;AACnD,UAAM,SAAS,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAO/B;AAEF,WAAO,OAAO,MAAM,EAAE,cAAc,CAAC,CAAC;AACtC,WAAO,OAAO,OAAO,KAAK,KAAK,EAAE,KAAK,aAAa;AAAA,EACrD,CAAC;AAED,KAAG,sCAAsC,YA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Q,2BAA2B;AAE/C,4BAAoB,KAAK,EAAE,QAAQ,IAAI,CAAC;AAAA,MAC1C;AAAA,IACF,CAAC;AAED,WAAO,OAAO,MAAM,EAAE,cAAc,CAAC,CAAC;AACtC,WAAO,mBAAmB,EAAE,aAAa,CAAC;AAAA,EAC5C,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,48 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { validate } from "./validate.js";
3
- describe("errors", () => {
4
- it("info required", async () => {
5
- const result = await validate({
6
- openapi: "3.1.0",
7
- paths: {}
8
- });
9
- expect(result).toMatchObject({
10
- errors: [
11
- {
12
- message: `must have required property 'info'`
13
- }
14
- ],
15
- valid: false
16
- });
17
- });
18
- it("unevaluated property", async () => {
19
- const spec = {
20
- openapi: "3.1.0",
21
- info: {
22
- title: "Hello World",
23
- version: "1.0.0"
24
- },
25
- paths: {
26
- "/test": {
27
- foobar: {
28
- responses: {
29
- 200: {
30
- description: "OK"
31
- }
32
- }
33
- }
34
- }
35
- }
36
- };
37
- const result = await validate(spec);
38
- expect(result).toMatchObject({
39
- errors: [
40
- {
41
- message: "Property foobar is not expected to be here"
42
- }
43
- ],
44
- valid: false
45
- });
46
- });
47
- });
48
- //# sourceMappingURL=errors.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/errors.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { validate } from './validate'\n\ndescribe('errors', () => {\n it('info required', async () => {\n const result = await validate({\n openapi: '3.1.0',\n paths: {},\n })\n\n expect(result).toMatchObject({\n errors: [\n {\n message: `must have required property 'info'`,\n },\n ],\n valid: false,\n })\n })\n\n it('unevaluated property', async () => {\n const spec = {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/test': {\n foobar: {\n responses: {\n 200: {\n description: 'OK',\n },\n },\n },\n },\n },\n }\n const result = await validate(spec)\n\n expect(result).toMatchObject({\n errors: [\n {\n message: 'Property foobar is not expected to be here',\n },\n ],\n valid: false,\n })\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,gBAAgB;AAEzB,SAAS,UAAU,MAAM;AACvB,KAAG,iBAAiB,YAAY;AAC9B,UAAM,SAAS,MAAM,SAAS;AAAA,MAC5B,SAAS;AAAA,MACT,OAAO,CAAC;AAAA,IACV,CAAC;AAED,WAAO,MAAM,EAAE,cAAc;AAAA,MAC3B,QAAQ;AAAA,QACN;AAAA,UACE,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,OAAO;AAAA,IACT,CAAC;AAAA,EACH,CAAC;AAED,KAAG,wBAAwB,YAAY;AACrC,UAAM,OAAO;AAAA,MACX,SAAS;AAAA,MACT,MAAM;AAAA,QACJ,OAAO;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,OAAO;AAAA,QACL,SAAS;AAAA,UACP,QAAQ;AAAA,YACN,WAAW;AAAA,cACT,KAAK;AAAA,gBACH,aAAa;AAAA,cACf;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,UAAM,SAAS,MAAM,SAAS,IAAI;AAElC,WAAO,MAAM,EAAE,cAAc;AAAA,MAC3B,QAAQ;AAAA,QACN;AAAA,UACE,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,OAAO;AAAA,IACT,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,11 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { escapeJsonPointer } from "./escape-json-pointer.js";
3
- describe("escapeJsonPointer", async () => {
4
- it("should escape a slash", () => {
5
- expect(escapeJsonPointer("application/json")).toBe("application~1json");
6
- });
7
- it("should escape multiple slashes", () => {
8
- expect(escapeJsonPointer("/api/users/{id}/reports")).toBe("~1api~1users~1{id}~1reports");
9
- });
10
- });
11
- //# sourceMappingURL=escape-json-pointer.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/escape-json-pointer.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { escapeJsonPointer } from './escape-json-pointer'\n\ndescribe('escapeJsonPointer', async () => {\n it('should escape a slash', () => {\n expect(escapeJsonPointer('application/json')).toBe('application~1json')\n })\n\n it('should escape multiple slashes', () => {\n expect(escapeJsonPointer('/api/users/{id}/reports')).toBe('~1api~1users~1{id}~1reports')\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,yBAAyB;AAElC,SAAS,qBAAqB,YAAY;AACxC,KAAG,yBAAyB,MAAM;AAChC,WAAO,kBAAkB,kBAAkB,CAAC,EAAE,KAAK,mBAAmB;AAAA,EACxE,CAAC;AAED,KAAG,kCAAkC,MAAM;AACzC,WAAO,kBAAkB,yBAAyB,CAAC,EAAE,KAAK,6BAA6B;AAAA,EACzF,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,18 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { getEntrypoint } from "./get-entrypoint.js";
3
- import { makeFilesystem } from "./make-filesystem.js";
4
- describe("getEntrypoint", () => {
5
- it("keeps the object reference", () => {
6
- const result = makeFilesystem({
7
- foo: "bar"
8
- });
9
- const entrypoint = getEntrypoint(result);
10
- entrypoint.specification.foo = "baz";
11
- expect(result[0].specification.foo).toBe("baz");
12
- });
13
- it("returns undefined for an empty filesystem", () => {
14
- const entrypoint = getEntrypoint([]);
15
- expect(entrypoint).toBe(void 0);
16
- });
17
- });
18
- //# sourceMappingURL=get-entrypoint.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/get-entrypoint.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { getEntrypoint } from './get-entrypoint'\nimport { makeFilesystem } from './make-filesystem'\n\ndescribe('getEntrypoint', () => {\n it('keeps the object reference', () => {\n const result = makeFilesystem({\n foo: 'bar',\n })\n\n const entrypoint = getEntrypoint(result)\n\n // Modify the entrypoint\n entrypoint.specification.foo = 'baz'\n\n // Check whether the original was modified\n expect(result[0].specification.foo).toBe('baz')\n })\n\n it('returns undefined for an empty filesystem', () => {\n const entrypoint = getEntrypoint([])\n\n // Check whether the original was modified\n expect(entrypoint).toBe(undefined)\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAE/B,SAAS,iBAAiB,MAAM;AAC9B,KAAG,8BAA8B,MAAM;AACrC,UAAM,SAAS,eAAe;AAAA,MAC5B,KAAK;AAAA,IACP,CAAC;AAED,UAAM,aAAa,cAAc,MAAM;AAGvC,eAAW,cAAc,MAAM;AAG/B,WAAO,OAAO,CAAC,EAAE,cAAc,GAAG,EAAE,KAAK,KAAK;AAAA,EAChD,CAAC;AAED,KAAG,6CAA6C,MAAM;AACpD,UAAM,aAAa,cAAc,CAAC,CAAC;AAGnC,WAAO,UAAU,EAAE,KAAK,MAAS;AAAA,EACnC,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,13 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { getSegmentsFromPath } from "./get-segments-from-path.js";
3
- describe("getSegmentsFromPath", () => {
4
- it("returns path segments", () => {
5
- const result = getSegmentsFromPath("/paths/test");
6
- expect(result).toEqual(["paths", "test"]);
7
- });
8
- it("unsescapes slashes", () => {
9
- const result = getSegmentsFromPath("/paths/~1test");
10
- expect(result).toEqual(["paths", "/test"]);
11
- });
12
- });
13
- //# sourceMappingURL=get-segments-from-path.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/get-segments-from-path.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { getSegmentsFromPath } from './get-segments-from-path'\n\ndescribe('getSegmentsFromPath', () => {\n it('returns path segments', () => {\n const result = getSegmentsFromPath('/paths/test')\n\n expect(result).toEqual(['paths', 'test'])\n })\n\n it('unsescapes slashes', () => {\n const result = getSegmentsFromPath('/paths/~1test')\n\n expect(result).toEqual(['paths', '/test'])\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,2BAA2B;AAEpC,SAAS,uBAAuB,MAAM;AACpC,KAAG,yBAAyB,MAAM;AAChC,UAAM,SAAS,oBAAoB,aAAa;AAEhD,WAAO,MAAM,EAAE,QAAQ,CAAC,SAAS,MAAM,CAAC;AAAA,EAC1C,CAAC;AAED,KAAG,sBAAsB,MAAM;AAC7B,UAAM,SAAS,oBAAoB,eAAe;AAElD,WAAO,MAAM,EAAE,QAAQ,CAAC,SAAS,OAAO,CAAC;AAAA,EAC3C,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,15 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { isFilesystem } from "./is-filesystem.js";
3
- import { makeFilesystem } from "./make-filesystem.js";
4
- describe("isFilesystem", () => {
5
- it("transforms an object to a filesystem", () => {
6
- const result = makeFilesystem({
7
- foo: "bar"
8
- });
9
- expect(result).not.toBe({
10
- foo: "bar"
11
- });
12
- expect(isFilesystem(result)).toBe(true);
13
- });
14
- });
15
- //# sourceMappingURL=is-filesystem.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/is-filesystem.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { isFilesystem } from './is-filesystem'\nimport { makeFilesystem } from './make-filesystem'\n\ndescribe('isFilesystem', () => {\n it('transforms an object to a filesystem', () => {\n const result = makeFilesystem({\n foo: 'bar',\n })\n\n expect(result).not.toBe({\n foo: 'bar',\n })\n\n expect(isFilesystem(result)).toBe(true)\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAE/B,SAAS,gBAAgB,MAAM;AAC7B,KAAG,wCAAwC,MAAM;AAC/C,UAAM,SAAS,eAAe;AAAA,MAC5B,KAAK;AAAA,IACP,CAAC;AAED,WAAO,MAAM,EAAE,IAAI,KAAK;AAAA,MACtB,KAAK;AAAA,IACP,CAAC;AAED,WAAO,aAAa,MAAM,CAAC,EAAE,KAAK,IAAI;AAAA,EACxC,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,23 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { isObject } from "./is-object.js";
3
- describe("isObject", () => {
4
- it("returns true for an object", () => {
5
- const result = isObject({
6
- foo: "bar"
7
- });
8
- expect(result).toBe(true);
9
- });
10
- it("returns true for an empty object", () => {
11
- const result = isObject({});
12
- expect(result).toBe(true);
13
- });
14
- it("returns false for a string", () => {
15
- const result = isObject("foo");
16
- expect(result).toBe(false);
17
- });
18
- it("returns false for an array", () => {
19
- const result = isObject([]);
20
- expect(result).toBe(false);
21
- });
22
- });
23
- //# sourceMappingURL=is-object.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/is-object.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { isObject } from './is-object'\n\ndescribe('isObject', () => {\n it('returns true for an object', () => {\n const result = isObject({\n foo: 'bar',\n })\n expect(result).toBe(true)\n })\n\n it('returns true for an empty object', () => {\n const result = isObject({})\n expect(result).toBe(true)\n })\n\n it('returns false for a string', () => {\n const result = isObject('foo')\n expect(result).toBe(false)\n })\n\n it('returns false for an array', () => {\n const result = isObject([])\n expect(result).toBe(false)\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,gBAAgB;AAEzB,SAAS,YAAY,MAAM;AACzB,KAAG,8BAA8B,MAAM;AACrC,UAAM,SAAS,SAAS;AAAA,MACtB,KAAK;AAAA,IACP,CAAC;AACD,WAAO,MAAM,EAAE,KAAK,IAAI;AAAA,EAC1B,CAAC;AAED,KAAG,oCAAoC,MAAM;AAC3C,UAAM,SAAS,SAAS,CAAC,CAAC;AAC1B,WAAO,MAAM,EAAE,KAAK,IAAI;AAAA,EAC1B,CAAC;AAED,KAAG,8BAA8B,MAAM;AACrC,UAAM,SAAS,SAAS,KAAK;AAC7B,WAAO,MAAM,EAAE,KAAK,KAAK;AAAA,EAC3B,CAAC;AAED,KAAG,8BAA8B,MAAM;AACrC,UAAM,SAAS,SAAS,CAAC,CAAC;AAC1B,WAAO,MAAM,EAAE,KAAK,KAAK;AAAA,EAC3B,CAAC;AACH,CAAC;",
6
- "names": []
7
- }