@scalar/oas-utils 0.3.2 → 0.4.1

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 (80) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/entities/spec/collection.d.ts +6 -12
  3. package/dist/entities/spec/collection.d.ts.map +1 -1
  4. package/dist/entities/spec/collection.js +1 -1
  5. package/dist/entities/spec/collection.js.map +2 -2
  6. package/dist/helpers/http-methods.js +9 -9
  7. package/dist/helpers/http-methods.js.map +1 -1
  8. package/dist/helpers/pretty-print-json.d.ts.map +1 -1
  9. package/dist/helpers/pretty-print-json.js.map +2 -2
  10. package/dist/transforms/import-spec.d.ts +8 -3
  11. package/dist/transforms/import-spec.d.ts.map +1 -1
  12. package/dist/transforms/import-spec.js +30 -9
  13. package/dist/transforms/import-spec.js.map +2 -2
  14. package/package.json +5 -5
  15. package/dist/entities/spec/operation.test.js +0 -43
  16. package/dist/entities/spec/operation.test.js.map +0 -7
  17. package/dist/entities/spec/parameters.test.js +0 -80
  18. package/dist/entities/spec/parameters.test.js.map +0 -7
  19. package/dist/entities/spec/request-example.test.js +0 -633
  20. package/dist/entities/spec/request-example.test.js.map +0 -7
  21. package/dist/entities/spec/server.test.js +0 -120
  22. package/dist/entities/spec/server.test.js.map +0 -7
  23. package/dist/entities/spec/spec-objects.test.js +0 -205
  24. package/dist/entities/spec/spec-objects.test.js.map +0 -7
  25. package/dist/entities/spec/x-scalar-environments.test.js +0 -11
  26. package/dist/entities/spec/x-scalar-environments.test.js.map +0 -7
  27. package/dist/entities/spec/x-scalar-secrets.test.js +0 -11
  28. package/dist/entities/spec/x-scalar-secrets.test.js.map +0 -7
  29. package/dist/helpers/ensure-protocol.test.js +0 -70
  30. package/dist/helpers/ensure-protocol.test.js.map +0 -7
  31. package/dist/helpers/fetch-document.test.js +0 -63
  32. package/dist/helpers/fetch-document.test.js.map +0 -7
  33. package/dist/helpers/find-variables.test.js +0 -20
  34. package/dist/helpers/find-variables.test.js.map +0 -7
  35. package/dist/helpers/is-defined.test.js +0 -37
  36. package/dist/helpers/is-defined.test.js.map +0 -7
  37. package/dist/helpers/is-local-url.test.js +0 -40
  38. package/dist/helpers/is-local-url.test.js.map +0 -7
  39. package/dist/helpers/is-valid-url.test.js +0 -17
  40. package/dist/helpers/is-valid-url.test.js.map +0 -7
  41. package/dist/helpers/json2xml.test.js +0 -19
  42. package/dist/helpers/json2xml.test.js.map +0 -7
  43. package/dist/helpers/make-url-absolute.test.js +0 -61
  44. package/dist/helpers/make-url-absolute.test.js.map +0 -7
  45. package/dist/helpers/merge-urls.test.js +0 -339
  46. package/dist/helpers/merge-urls.test.js.map +0 -7
  47. package/dist/helpers/normalize-mime-type-object.test.js +0 -53
  48. package/dist/helpers/normalize-mime-type-object.test.js.map +0 -7
  49. package/dist/helpers/normalize-mime-type.test.js +0 -33
  50. package/dist/helpers/normalize-mime-type.test.js.map +0 -7
  51. package/dist/helpers/omit-undefined-values.test.js +0 -89
  52. package/dist/helpers/omit-undefined-values.test.js.map +0 -7
  53. package/dist/helpers/parse.test.js +0 -45
  54. package/dist/helpers/parse.test.js.map +0 -7
  55. package/dist/helpers/pretty-print-json.test.js +0 -28
  56. package/dist/helpers/pretty-print-json.test.js.map +0 -7
  57. package/dist/helpers/redirect-to-proxy.test.js +0 -54
  58. package/dist/helpers/redirect-to-proxy.test.js.map +0 -7
  59. package/dist/helpers/regex-helpers.test.js +0 -154
  60. package/dist/helpers/regex-helpers.test.js.map +0 -7
  61. package/dist/helpers/replace-variables.test.js +0 -30
  62. package/dist/helpers/replace-variables.test.js.map +0 -7
  63. package/dist/helpers/security/get-schemes.test.js +0 -71
  64. package/dist/helpers/security/get-schemes.test.js.map +0 -7
  65. package/dist/helpers/security/has-token.test.js +0 -157
  66. package/dist/helpers/security/has-token.test.js.map +0 -7
  67. package/dist/migrations/semver.test.js +0 -21
  68. package/dist/migrations/semver.test.js.map +0 -7
  69. package/dist/migrations/v-2.4.0/migration.test.js +0 -90
  70. package/dist/migrations/v-2.4.0/migration.test.js.map +0 -7
  71. package/dist/migrations/v-2.5.0/migration.test.js +0 -108
  72. package/dist/migrations/v-2.5.0/migration.test.js.map +0 -7
  73. package/dist/spec-getters/get-example-from-schema.test.js +0 -1092
  74. package/dist/spec-getters/get-example-from-schema.test.js.map +0 -7
  75. package/dist/spec-getters/get-parameters-from-operation.test.js +0 -178
  76. package/dist/spec-getters/get-parameters-from-operation.test.js.map +0 -7
  77. package/dist/spec-getters/get-request-body-from-operation.test.js +0 -289
  78. package/dist/spec-getters/get-request-body-from-operation.test.js.map +0 -7
  79. package/dist/transforms/import-spec.test.js +0 -1124
  80. package/dist/transforms/import-spec.test.js.map +0 -7
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/request-example.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { operationSchema } from './operation'\nimport {\n convertExampleToXScalar,\n createExampleFromRequest,\n createParamInstance,\n parameterArrayToObject,\n requestExampleSchema,\n} from './request-examples'\n\ndescribe('createParamInstance', () => {\n it('works with schema enum type number', () => {\n const result = createParamInstance({\n in: 'path',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 1.2,\n type: 'number',\n enum: [1.2, 2.1, 3],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '1.2',\n enabled: true,\n description: undefined,\n required: true,\n enum: ['1.2', '2.1', '3'],\n type: 'number',\n default: 1.2,\n })\n })\n\n it('works with schema enum type string', () => {\n const result = createParamInstance({\n in: 'path',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 'foo',\n type: 'string',\n enum: ['foo', 'bar'],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: 'foo',\n enabled: true,\n description: undefined,\n required: true,\n enum: ['foo', 'bar'],\n type: 'string',\n default: 'foo',\n })\n })\n\n it('works with schema enum type integer', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 1,\n type: 'integer',\n enum: [1, 2, 3],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '1',\n enabled: true,\n description: undefined,\n required: true,\n enum: ['1', '2', '3'],\n type: 'integer',\n default: 1,\n })\n })\n\n it('works with schema enum type boolean', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: false,\n type: 'boolean',\n enum: [true, false],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: 'false',\n enabled: true,\n description: undefined,\n required: true,\n enum: ['true', 'false'],\n type: 'boolean',\n default: false,\n })\n })\n\n it('works with schema examples type number', () => {\n const result = createParamInstance({\n in: 'path',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 1.2,\n type: 'number',\n examples: [1.2, 2.1, 3],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '1.2',\n enabled: true,\n description: undefined,\n required: true,\n examples: ['1.2', '2.1', '3'],\n type: 'number',\n default: 1.2,\n })\n })\n\n it('works with schema examples type string', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: false,\n type: 'boolean',\n examples: ['foo', 'bar'],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: 'false',\n enabled: true,\n description: undefined,\n required: true,\n type: 'boolean',\n default: false,\n examples: ['foo', 'bar'],\n })\n })\n\n it('works with schema examples type integer', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 1,\n type: 'integer',\n examples: [1, 2, 3],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '1',\n enabled: true,\n description: undefined,\n required: true,\n examples: ['1', '2', '3'],\n type: 'integer',\n default: 1,\n })\n })\n\n it('works with schema examples type boolean', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: false,\n type: 'boolean',\n examples: [true, false],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: 'false',\n enabled: true,\n description: undefined,\n required: true,\n examples: ['true', 'false'],\n type: 'boolean',\n default: false,\n })\n })\n\n it('works with array of types', () => {\n const result = createParamInstance({\n in: 'path',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n type: ['string', 'null'],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n enabled: true,\n enum: undefined,\n examples: undefined,\n description: undefined,\n required: true,\n type: 'string',\n nullable: true,\n value: '',\n })\n })\n\n it('works with content examples', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: false,\n deprecated: false,\n content: {\n 'application/json': {\n schema: { type: 'integer', maximum: 50 },\n examples: {\n zero: { value: 0 },\n max: { value: 50 },\n },\n },\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '0',\n enabled: false,\n description: undefined,\n required: false,\n })\n })\n\n it('works with content example', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: false,\n deprecated: false,\n content: {\n 'application/json': {\n schema: { type: 'integer' },\n example: 42,\n },\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '42',\n enabled: false,\n description: undefined,\n required: false,\n })\n })\n\n it('works with parameter example', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: false,\n deprecated: false,\n example: 42,\n schema: {\n type: 'integer',\n example: 1,\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '42',\n enabled: false,\n description: undefined,\n required: false,\n type: 'integer',\n })\n })\n})\n\ndescribe('parameterArrayToObject', () => {\n it('converts array of parameters to key-value object', () => {\n const params = [\n { key: 'foo', value: 'bar', enabled: true },\n { key: 'hello', value: 'world', enabled: false },\n ]\n\n const result = parameterArrayToObject(params)\n\n expect(result).toEqual({\n foo: 'bar',\n hello: 'world',\n })\n })\n\n it('handles empty array', () => {\n const result = parameterArrayToObject([])\n expect(result).toEqual({})\n })\n})\n\ndescribe('convertExampleToXScalar', () => {\n it('converts raw JSON body', () => {\n const example = requestExampleSchema.parse({\n uid: 'test-uid',\n requestUid: 'req-uid',\n body: {\n activeBody: 'raw',\n raw: {\n encoding: 'json' as const,\n value: '{\"test\": true}',\n },\n },\n parameters: {\n path: [{ key: 'id', value: '123', enabled: true }],\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n },\n })\n\n const result = convertExampleToXScalar(example)\n\n expect(result).toEqual({\n body: {\n encoding: 'application/json',\n content: '{\"test\": true}',\n },\n parameters: {\n path: { id: '123' },\n headers: { Accept: '*/*' },\n },\n })\n })\n\n it('converts form data body', () => {\n const example = requestExampleSchema.parse({\n uid: 'test-uid',\n requestUid: 'req-uid',\n body: {\n activeBody: 'formData',\n formData: {\n encoding: 'form-data' as const,\n value: [\n { key: 'field1', value: 'value1', enabled: true },\n {\n key: 'file1',\n value: 'ignore this',\n file: new File(['test content'], 'test.txt', { type: 'text/plain' }),\n enabled: true,\n },\n ],\n },\n },\n })\n\n const result = convertExampleToXScalar(example)\n\n expect(result).toEqual({\n body: {\n encoding: 'multipart/form-data',\n content: {\n field1: { type: 'string', value: 'value1' },\n file1: { type: 'file', file: null },\n },\n },\n parameters: {\n headers: {\n Accept: '*/*',\n },\n },\n })\n })\n\n it('converts binary body', () => {\n const example = requestExampleSchema.parse({\n uid: 'test-uid',\n requestUid: 'req-uid',\n body: {\n activeBody: 'binary',\n binary: new Blob(['test']),\n },\n })\n\n const result = convertExampleToXScalar(example)\n\n expect(result).toEqual({\n body: {\n encoding: 'binary',\n content: '',\n file: null,\n },\n parameters: {\n headers: {\n Accept: '*/*',\n },\n },\n })\n })\n})\n\ndescribe('createExampleFromRequest', () => {\n it('creates example with JSON request body', () => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [\n {\n in: 'path',\n name: 'id',\n required: true,\n deprecated: false,\n schema: { type: 'string', default: '123' },\n },\n ],\n requestBody: {\n content: {\n 'application/json': {\n schema: {},\n example: '{\"test\": true}',\n },\n },\n },\n })\n\n const result = createExampleFromRequest(operation, 'Test Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Test Example',\n body: {\n activeBody: 'raw',\n raw: {\n encoding: 'json',\n value: '{\"test\": true}',\n },\n },\n parameters: {\n path: [\n {\n key: 'id',\n value: '123',\n enabled: true,\n required: true,\n },\n ],\n headers: [\n { key: 'Accept', value: '*/*', enabled: true },\n { key: 'Content-Type', value: 'application/json', enabled: true },\n ],\n query: [],\n cookies: [],\n },\n })\n })\n\n it('does not overwrite the content-type header if it exists', () => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [\n {\n in: 'path',\n name: 'id',\n required: true,\n deprecated: false,\n schema: { type: 'string', default: '123' },\n },\n {\n in: 'header',\n name: 'Content-Type',\n required: true,\n deprecated: false,\n schema: { type: 'string', default: 'application/testing' },\n },\n ],\n requestBody: {\n content: {\n 'application/json': {\n schema: {},\n example: '{\"test\": true}',\n },\n },\n },\n })\n\n const result = createExampleFromRequest(operation, 'Test Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Test Example',\n body: {\n activeBody: 'raw',\n raw: {\n encoding: 'json',\n value: '{\"test\": true}',\n },\n },\n parameters: {\n path: [\n {\n key: 'id',\n value: '123',\n enabled: true,\n required: true,\n },\n ],\n headers: [{ key: 'Content-Type', value: 'application/testing', enabled: true }],\n query: [],\n cookies: [],\n },\n })\n })\n\n it('creates example with form-data request body', () => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [],\n requestBody: {\n content: {\n 'multipart/form-data': {\n schema: {\n type: 'object',\n properties: {\n image: {\n type: 'string',\n format: 'binary',\n description: \"The pet's image file\",\n },\n additionalImages: {\n type: 'array',\n items: {\n type: 'string',\n format: 'binary',\n },\n description: 'Additional pet images',\n },\n metadata: {\n type: 'object',\n properties: {\n caption: {\n type: 'string',\n },\n tags: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n },\n },\n },\n })\n\n const result = createExampleFromRequest(operation, 'Form Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Form Example',\n body: {\n activeBody: 'formData',\n formData: {\n encoding: 'form-data',\n value: [\n { key: 'image', value: 'BINARY', file: expect.any(File), enabled: true },\n { key: 'additionalImages', value: 'BINARY', file: expect.any(File), enabled: true },\n { key: 'metadata', value: '{\"caption\":\"\",\"tags\":[\"\"]}', enabled: true },\n ],\n },\n },\n parameters: {\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n path: [],\n query: [],\n cookies: [],\n },\n })\n })\n})\n\ndescribe('createExampleFromRequest with default body when Content-Type header is exists', () => {\n it.each([\n { contentType: 'application/json', defaultBody: { activeBody: 'raw', raw: { encoding: 'json', value: '{}' } } },\n { contentType: 'application/xml', defaultBody: { activeBody: 'raw', raw: { encoding: 'xml', value: '' } } },\n { contentType: 'application/octet-stream', defaultBody: { activeBody: 'binary', binary: undefined } },\n {\n contentType: 'application/x-www-form-urlencoded',\n defaultBody: { activeBody: 'formData', formData: { encoding: 'urlencoded', value: [] } },\n },\n {\n contentType: 'multipart/form-data',\n defaultBody: { activeBody: 'formData', formData: { encoding: 'form-data', value: [] } },\n },\n ] as const)('when Content-Type header is $contentType', ({ contentType, defaultBody }) => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [\n {\n in: 'header',\n name: 'Content-Type',\n required: true,\n deprecated: false,\n schema: { type: 'string', default: contentType },\n },\n ],\n })\n\n const result = createExampleFromRequest(operation, 'Test Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Test Example',\n body: defaultBody,\n parameters: {\n headers: [{ key: 'Content-Type', value: contentType, enabled: true }],\n query: [],\n cookies: [],\n },\n })\n })\n\n it('when Content-Type header is not exists', () => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [\n {\n in: 'header',\n name: 'Content-Type',\n required: true,\n deprecated: false,\n schema: { type: 'string' },\n },\n ],\n })\n\n const result = createExampleFromRequest(operation, 'Test Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Test Example',\n body: {\n activeBody: 'raw',\n },\n parameters: {\n headers: [{ key: 'Content-Type', value: '', enabled: true }],\n query: [],\n cookies: [],\n },\n })\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,uBAAuB,MAAM;AACpC,KAAG,sCAAsC,MAAM;AAC7C,UAAM,SAAS,oBAAoB;AAAA,MACjC,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,MAAM;AAAA,QACN,MAAM,CAAC,KAAK,KAAK,CAAC;AAAA,MACpB;AAAA,IACF,CAAC;AAED,WAAO,MAAM,EAAE,QAAQ;AAAA,MACrB,KAAK;AAAA,MACL,OAAO;AAAA,MACP,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,MAAM,CAAC,OAAO,OAAO,GAAG;AAAA,MACxB,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AAAA,EACH,CAAC;AAED,KAAG,sCAAsC,MAAM;AAC7C,UAAM,SAAS,oBAAoB;AAAA,MACjC,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,MAAM;AAAA,QACN,MAAM,CAAC,OAAO,KAAK;AAAA,MACrB;AAAA,IACF,CAAC;AAED,WAAO,MAAM,EAAE,QAAQ;AAAA,MACrB,KAAK;AAAA,MACL,OAAO;AAAA,MACP,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,MAAM,CAAC,OAAO,KAAK;AAAA,MACnB,MAAM;AAAA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serverSchema } from "./server.js";
3
- describe("serverSchema", () => {
4
- it("validates valid server object", () => {
5
- const server = { url: "https://api.example.com" };
6
- expect(serverSchema.parse(server)).toMatchObject(server);
7
- });
8
- it("validates server with description", () => {
9
- const server = {
10
- url: "https://api.example.com",
11
- description: "Production API"
12
- };
13
- expect(serverSchema.parse(server)).toMatchObject(server);
14
- });
15
- it("validates server with variables", () => {
16
- const server = {
17
- url: "https://{username}.example.com",
18
- variables: {
19
- username: {
20
- default: "demo"
21
- }
22
- }
23
- };
24
- expect(serverSchema.parse(server)).toMatchObject(server);
25
- });
26
- it("validates server with enum variables", () => {
27
- const server = {
28
- url: "https://{environment}.example.com",
29
- variables: {
30
- environment: {
31
- enum: ["dev", "staging", "prod"],
32
- default: "dev",
33
- description: "Environment selection"
34
- },
35
- username: {
36
- // invalid enum
37
- enum: [],
38
- default: "demo",
39
- description: "Username selection"
40
- },
41
- version: {
42
- enum: ["v1", "v2"],
43
- description: "Version selection"
44
- }
45
- }
46
- };
47
- expect(serverSchema.parse(server)).toStrictEqual({
48
- uid: expect.any(String),
49
- url: "https://{environment}.example.com",
50
- variables: {
51
- environment: {
52
- enum: ["dev", "staging", "prod"],
53
- // kept
54
- default: "dev",
55
- description: "Environment selection"
56
- },
57
- username: {
58
- // enum omitted
59
- default: "demo",
60
- description: "Username selection"
61
- },
62
- version: {
63
- enum: ["v1", "v2"],
64
- // added
65
- default: "v1",
66
- description: "Version selection"
67
- }
68
- }
69
- });
70
- });
71
- it("fails when URL is missing", () => {
72
- const server = {};
73
- expect(() => serverSchema.parse(server)).toThrow();
74
- });
75
- it("fails when variable default is not in enum", () => {
76
- const server = {
77
- url: "https://{environment}.example.com",
78
- variables: {
79
- environment: {
80
- enum: ["dev", "staging", "prod"],
81
- default: "invalid",
82
- description: "Environment selection"
83
- }
84
- }
85
- };
86
- expect(serverSchema.parse(server)).toMatchObject({
87
- url: "https://{environment}.example.com",
88
- variables: {
89
- environment: {
90
- enum: ["dev", "staging", "prod"],
91
- default: "dev",
92
- description: "Environment selection"
93
- }
94
- }
95
- });
96
- });
97
- it("validates server with relative URL", () => {
98
- const server = {
99
- url: "/api/v1",
100
- description: "Relative URL"
101
- };
102
- expect(serverSchema.parse(server)).toMatchObject(server);
103
- });
104
- it("validates server with multiple variables", () => {
105
- const server = {
106
- url: "https://{username}.{domain}.com",
107
- variables: {
108
- username: {
109
- default: "demo"
110
- },
111
- domain: {
112
- enum: ["example", "test"],
113
- default: "example"
114
- }
115
- }
116
- };
117
- expect(serverSchema.parse(server)).toMatchObject(server);
118
- });
119
- });
120
- //# sourceMappingURL=server.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/server.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { serverSchema } from './server'\n\ndescribe('serverSchema', () => {\n it('validates valid server object', () => {\n const server = { url: 'https://api.example.com' }\n expect(serverSchema.parse(server)).toMatchObject(server)\n })\n\n it('validates server with description', () => {\n const server = {\n url: 'https://api.example.com',\n description: 'Production API',\n }\n expect(serverSchema.parse(server)).toMatchObject(server)\n })\n\n it('validates server with variables', () => {\n const server = {\n url: 'https://{username}.example.com',\n variables: {\n username: {\n default: 'demo',\n },\n },\n }\n expect(serverSchema.parse(server)).toMatchObject(server)\n })\n\n it('validates server with enum variables', () => {\n const server = {\n url: 'https://{environment}.example.com',\n variables: {\n environment: {\n enum: ['dev', 'staging', 'prod'],\n default: 'dev',\n description: 'Environment selection',\n },\n username: {\n // invalid enum\n enum: [],\n default: 'demo',\n description: 'Username selection',\n },\n version: {\n enum: ['v1', 'v2'],\n description: 'Version selection',\n },\n },\n }\n\n expect(serverSchema.parse(server)).toStrictEqual({\n uid: expect.any(String),\n url: 'https://{environment}.example.com',\n variables: {\n environment: {\n enum: ['dev', 'staging', 'prod'],\n // kept\n default: 'dev',\n description: 'Environment selection',\n },\n username: {\n // enum omitted\n default: 'demo',\n description: 'Username selection',\n },\n version: {\n enum: ['v1', 'v2'],\n // added\n default: 'v1',\n description: 'Version selection',\n },\n },\n })\n })\n\n it('fails when URL is missing', () => {\n const server = {}\n expect(() => serverSchema.parse(server)).toThrow()\n })\n\n it('fails when variable default is not in enum', () => {\n const server = {\n url: 'https://{environment}.example.com',\n variables: {\n environment: {\n enum: ['dev', 'staging', 'prod'],\n default: 'invalid',\n description: 'Environment selection',\n },\n },\n }\n\n expect(serverSchema.parse(server)).toMatchObject({\n url: 'https://{environment}.example.com',\n variables: {\n environment: {\n enum: ['dev', 'staging', 'prod'],\n default: 'dev',\n description: 'Environment selection',\n },\n },\n })\n })\n\n it('validates server with relative URL', () => {\n const server = {\n url: '/api/v1',\n description: 'Relative URL',\n }\n expect(serverSchema.parse(server)).toMatchObject(server)\n })\n\n it('validates server with multiple variables', () => {\n const server = {\n url: 'https://{username}.{domain}.com',\n variables: {\n username: {\n default: 'demo',\n },\n domain: {\n enum: ['example', 'test'],\n default: 'example',\n },\n },\n }\n expect(serverSchema.parse(server)).toMatchObject(server)\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB,MAAM;AAC7B,KAAG,iCAAiC,MAAM;AACxC,UAAM,SAAS,EAAE,KAAK,0BAA0B;AAChD,WAAO,aAAa,MAAM,MAAM,CAAC,EAAE,cAAc,MAAM;AAAA,EACzD,CAAC;AAED,KAAG,qCAAqC,MAAM;AAC5C,UAAM,SAAS;AAAA,MACb,KAAK;AAAA,MACL,aAAa;AAAA,IACf;AACA,WAAO,aAAa,MAAM,MAAM,CAAC,EAAE,cAAc,MAAM;AAAA,EACzD,CAAC;AAED,KAAG,mCAAmC,MAAM;AAC1C,UAAM,SAAS;AAAA,MACb,KAAK;AAAA,MACL,WAAW;AAAA,QACT,UAAU;AAAA,UACR,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AACA,WAAO,aAAa,MAAM,MAAM,CAAC,EAAE,cAAc,MAAM;AAAA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AA,MACL,WAAW;AAAA,QACT,aAAa;AAAA,UACX,MAAM,CAAC,OAAO,WAAW,MAAM;AAAA,UAC/B,SAAS;AAAA,UACT,aAAa;AAAA,QACf;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,KAAG,sCAAsC,MAAM;AAC7C,UAAM,SAAS;AAAA,MACb,KAAK;AAAA,MACL,aAAa;AAAA,IACf;AACA,WAAO,aAAa,MAAM,MAAM,CAAC,EAAE,cAAc,MAAM;AAAA,EACzD,CAAC;AAED,KAAG,4CAA4C,MAAM;AACnD,UAAM,SAAS;AAAA,MACb,KAAK;AAAA,MACL,WAAW;AAAA,QACT,UAAU;AAAA,UACR,SAAS;AAAA,QACX;AAAA,QACA,QAAQ;AAAA,UACN,MAAM,CAAC,WAAW,MAAM;AAAA,UACxB,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AACA,WAAO,aAAa,MAAM,MAAM,CAAC,EAAE,cAAc,MAAM;AAAA,EACzD,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,205 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { oasInfoSchema } from "./spec-objects.js";
3
- describe("spec-objects", () => {
4
- describe("oasInfoSchema", () => {
5
- describe("title", () => {
6
- it("parses title", () => {
7
- const title = oasInfoSchema.parse({
8
- title: "My API"
9
- });
10
- expect(title).toMatchObject({
11
- title: "My API"
12
- });
13
- });
14
- it("defaults to API", () => {
15
- const title = oasInfoSchema.parse({});
16
- expect(title).toMatchObject({
17
- title: "API"
18
- });
19
- });
20
- it("ignores invalid title", () => {
21
- const title = oasInfoSchema.parse({
22
- title: 123
23
- });
24
- expect(title).toMatchObject({ title: "API" });
25
- });
26
- });
27
- describe("summary", () => {
28
- it("parses summary", () => {
29
- const info = oasInfoSchema.parse({
30
- summary: "A brief summary of the API"
31
- });
32
- expect(info).toMatchObject({
33
- summary: "A brief summary of the API"
34
- });
35
- });
36
- it("ignores invalid summary", () => {
37
- const info = oasInfoSchema.parse({
38
- summary: 123
39
- });
40
- expect(info.summary).toBeUndefined();
41
- });
42
- });
43
- describe("description", () => {
44
- it("parses description", () => {
45
- const info = oasInfoSchema.parse({
46
- description: "A detailed description of the API"
47
- });
48
- expect(info).toMatchObject({
49
- description: "A detailed description of the API"
50
- });
51
- });
52
- it("ignores invalid description", () => {
53
- const info = oasInfoSchema.parse({
54
- description: 123
55
- });
56
- expect(info.description).toBeUndefined();
57
- });
58
- });
59
- describe("version", () => {
60
- it("parses version", () => {
61
- const version = oasInfoSchema.parse({
62
- version: "1.0.0"
63
- });
64
- expect(version).toMatchObject({ version: "1.0.0" });
65
- });
66
- it("defaults to 1.0", () => {
67
- const version = oasInfoSchema.parse({});
68
- expect(version).toMatchObject({ version: "1.0" });
69
- });
70
- it("ignores invalid version", () => {
71
- const version = oasInfoSchema.parse({
72
- version: 123
73
- });
74
- expect(version).toMatchObject({ version: "1.0" });
75
- });
76
- });
77
- describe("contact", () => {
78
- it("parses contact object", () => {
79
- const info = oasInfoSchema.parse({
80
- contact: {
81
- name: "John Doe",
82
- url: "https://example.com",
83
- email: "john.doe@example.com"
84
- }
85
- });
86
- expect(info).toMatchObject({
87
- contact: {
88
- name: "John Doe",
89
- url: "https://example.com",
90
- email: "john.doe@example.com"
91
- }
92
- });
93
- });
94
- it("ignores invalid contact", () => {
95
- const info = oasInfoSchema.parse({
96
- contact: 123
97
- });
98
- expect(info.contact).toStrictEqual(void 0);
99
- });
100
- it("works with just the name", () => {
101
- const info = oasInfoSchema.parse({
102
- contact: {
103
- name: "John Doe"
104
- }
105
- });
106
- expect(info).toMatchObject({
107
- contact: {
108
- name: "John Doe"
109
- }
110
- });
111
- });
112
- it("works with just the url", () => {
113
- const info = oasInfoSchema.parse({
114
- contact: {
115
- url: "https://example.com"
116
- }
117
- });
118
- expect(info).toMatchObject({
119
- contact: {
120
- url: "https://example.com"
121
- }
122
- });
123
- });
124
- it("works with just the email", () => {
125
- const info = oasInfoSchema.parse({
126
- contact: {
127
- email: "john.doe@example.com"
128
- }
129
- });
130
- expect(info).toMatchObject({
131
- contact: {
132
- email: "john.doe@example.com"
133
- }
134
- });
135
- });
136
- it("keeps invalid emails", () => {
137
- const info = oasInfoSchema.parse({
138
- contact: {
139
- name: "John Doe",
140
- url: "invalid",
141
- email: "invalid",
142
- something: "random"
143
- }
144
- });
145
- expect(info.contact).toStrictEqual({
146
- name: "John Doe",
147
- email: "invalid"
148
- });
149
- });
150
- });
151
- describe("license", () => {
152
- it("parses license object", () => {
153
- const info = oasInfoSchema.parse({
154
- license: {
155
- name: "MIT",
156
- url: "https://opensource.org/licenses/MIT",
157
- identifier: "MIT"
158
- }
159
- });
160
- expect(info).toMatchObject({
161
- license: {
162
- name: "MIT",
163
- url: "https://opensource.org/licenses/MIT",
164
- identifier: "MIT"
165
- }
166
- });
167
- });
168
- it("ignores invalid license", () => {
169
- const info = oasInfoSchema.parse({
170
- license: 123
171
- });
172
- expect(info.license).toStrictEqual(void 0);
173
- });
174
- it("works with just the name", () => {
175
- const info = oasInfoSchema.parse({
176
- license: {
177
- name: "MIT"
178
- }
179
- });
180
- expect(info).toMatchObject({
181
- license: {
182
- name: "MIT"
183
- }
184
- });
185
- });
186
- });
187
- describe("termsOfService", () => {
188
- it("parses termsOfService", () => {
189
- const info = oasInfoSchema.parse({
190
- termsOfService: "https://example.com/terms-of-service"
191
- });
192
- expect(info).toMatchObject({
193
- termsOfService: "https://example.com/terms-of-service"
194
- });
195
- });
196
- it("ignores invalid termsOfService", () => {
197
- const info = oasInfoSchema.parse({
198
- termsOfService: 123
199
- });
200
- expect(info.termsOfService).toStrictEqual(void 0);
201
- });
202
- });
203
- });
204
- });
205
- //# sourceMappingURL=spec-objects.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/spec-objects.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { oasInfoSchema } from './spec-objects'\n\ndescribe('spec-objects', () => {\n describe('oasInfoSchema', () => {\n describe('title', () => {\n it('parses title', () => {\n const title = oasInfoSchema.parse({\n title: 'My API',\n })\n\n expect(title).toMatchObject({\n title: 'My API',\n })\n })\n\n it('defaults to API', () => {\n const title = oasInfoSchema.parse({})\n\n expect(title).toMatchObject({\n title: 'API',\n })\n })\n\n it('ignores invalid title', () => {\n const title = oasInfoSchema.parse({\n title: 123,\n })\n\n expect(title).toMatchObject({ title: 'API' })\n })\n })\n\n describe('summary', () => {\n it('parses summary', () => {\n const info = oasInfoSchema.parse({\n summary: 'A brief summary of the API',\n })\n\n expect(info).toMatchObject({\n summary: 'A brief summary of the API',\n })\n })\n\n it('ignores invalid summary', () => {\n const info = oasInfoSchema.parse({\n summary: 123,\n })\n\n expect(info.summary).toBeUndefined()\n })\n })\n\n describe('description', () => {\n it('parses description', () => {\n const info = oasInfoSchema.parse({\n description: 'A detailed description of the API',\n })\n\n expect(info).toMatchObject({\n description: 'A detailed description of the API',\n })\n })\n\n it('ignores invalid description', () => {\n const info = oasInfoSchema.parse({\n description: 123,\n })\n\n expect(info.description).toBeUndefined()\n })\n })\n\n describe('version', () => {\n it('parses version', () => {\n const version = oasInfoSchema.parse({\n version: '1.0.0',\n })\n\n expect(version).toMatchObject({ version: '1.0.0' })\n })\n\n it('defaults to 1.0', () => {\n const version = oasInfoSchema.parse({})\n\n expect(version).toMatchObject({ version: '1.0' })\n })\n\n it('ignores invalid version', () => {\n const version = oasInfoSchema.parse({\n version: 123,\n })\n\n expect(version).toMatchObject({ version: '1.0' })\n })\n })\n\n describe('contact', () => {\n it('parses contact object', () => {\n const info = oasInfoSchema.parse({\n contact: {\n name: 'John Doe',\n url: 'https://example.com',\n email: 'john.doe@example.com',\n },\n })\n\n expect(info).toMatchObject({\n contact: {\n name: 'John Doe',\n url: 'https://example.com',\n email: 'john.doe@example.com',\n },\n })\n })\n\n it('ignores invalid contact', () => {\n const info = oasInfoSchema.parse({\n contact: 123,\n })\n\n expect(info.contact).toStrictEqual(undefined)\n })\n\n it('works with just the name', () => {\n const info = oasInfoSchema.parse({\n contact: {\n name: 'John Doe',\n },\n })\n\n expect(info).toMatchObject({\n contact: {\n name: 'John Doe',\n },\n })\n })\n\n it('works with just the url', () => {\n const info = oasInfoSchema.parse({\n contact: {\n url: 'https://example.com',\n },\n })\n\n expect(info).toMatchObject({\n contact: {\n url: 'https://example.com',\n },\n })\n })\n\n it('works with just the email', () => {\n const info = oasInfoSchema.parse({\n contact: {\n email: 'john.doe@example.com',\n },\n })\n\n expect(info).toMatchObject({\n contact: {\n email: 'john.doe@example.com',\n },\n })\n })\n\n it('keeps invalid emails', () => {\n const info = oasInfoSchema.parse({\n contact: {\n name: 'John Doe',\n url: 'invalid',\n email: 'invalid',\n something: 'random',\n },\n })\n\n expect(info.contact).toStrictEqual({\n name: 'John Doe',\n email: 'invalid',\n })\n })\n })\n\n describe('license', () => {\n it('parses license object', () => {\n const info = oasInfoSchema.parse({\n license: {\n name: 'MIT',\n url: 'https://opensource.org/licenses/MIT',\n identifier: 'MIT',\n },\n })\n\n expect(info).toMatchObject({\n license: {\n name: 'MIT',\n url: 'https://opensource.org/licenses/MIT',\n identifier: 'MIT',\n },\n })\n })\n\n it('ignores invalid license', () => {\n const info = oasInfoSchema.parse({\n license: 123,\n })\n\n expect(info.license).toStrictEqual(undefined)\n })\n\n it('works with just the name', () => {\n const info = oasInfoSchema.parse({\n license: {\n name: 'MIT',\n },\n })\n\n expect(info).toMatchObject({\n license: {\n name: 'MIT',\n },\n })\n })\n })\n\n describe('termsOfService', () => {\n it('parses termsOfService', () => {\n const info = oasInfoSchema.parse({\n termsOfService: 'https://example.com/terms-of-service',\n })\n\n expect(info).toMatchObject({\n termsOfService: 'https://example.com/terms-of-service',\n })\n })\n\n it('ignores invalid termsOfService', () => {\n const info = oasInfoSchema.parse({\n termsOfService: 123,\n })\n\n expect(info.termsOfService).toStrictEqual(undefined)\n })\n })\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AA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KAAK,OAAO,EAAE,cAAc,MAAS;AAAA,MAC9C,CAAC;AAED,SAAG,4BAA4B,MAAM;AACnC,cAAM,OAAO,cAAc,MAAM;AAAA,UAC/B,SAAS;AAAA,YACP,MAAM;AAAA,UACR;AAAA,QACF,CAAC;AAED,eAAO,IAAI,EAAE,cAAc;AAAA,UACzB,SAAS;AAAA,YACP,MAAM;AAAA,UACR;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAED,aAAS,kBAAkB,MAAM;AAC/B,SAAG,yBAAyB,MAAM;AAChC,cAAM,OAAO,cAAc,MAAM;AAAA,UAC/B,gBAAgB;AAAA,QAClB,CAAC;AAED,eAAO,IAAI,EAAE,cAAc;AAAA,UACzB,gBAAgB;AAAA,QAClB,CAAC;AAAA,MACH,CAAC;AAED,SAAG,kCAAkC,MAAM;AACzC,cAAM,OAAO,cAAc,MAAM;AAAA,UAC/B,gBAAgB;AAAA,QAClB,CAAC;AAED,eAAO,KAAK,cAAc,EAAE,cAAc,MAAS;AAAA,MACrD,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,11 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { parseJsonOrYaml } from "../../helpers/parse.js";
3
- import baseDefinition from "@/spec-extentions/x-scalar-environments.yaml?raw";
4
- import { xScalarEnvironmentsSchema } from "./x-scalar-environments.js";
5
- describe("x-scalar-environments", () => {
6
- it("Handles spec definition", () => {
7
- const parsed = parseJsonOrYaml(baseDefinition);
8
- expect(xScalarEnvironmentsSchema.parse(parsed["x-scalar-environments"])).toEqual(parsed["x-scalar-environments"]);
9
- });
10
- });
11
- //# sourceMappingURL=x-scalar-environments.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/x-scalar-environments.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { parseJsonOrYaml } from '@/helpers/parse'\nimport baseDefinition from '@/spec-extentions/x-scalar-environments.yaml?raw'\nimport { xScalarEnvironmentsSchema } from './x-scalar-environments'\n\ndescribe('x-scalar-environments', () => {\n it('Handles spec definition', () => {\n const parsed = parseJsonOrYaml(baseDefinition)\n\n expect(xScalarEnvironmentsSchema.parse(parsed['x-scalar-environments'])).toEqual(parsed['x-scalar-environments'])\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,uBAAuB;AAChC,OAAO,oBAAoB;AAC3B,SAAS,iCAAiC;AAE1C,SAAS,yBAAyB,MAAM;AACtC,KAAG,2BAA2B,MAAM;AAClC,UAAM,SAAS,gBAAgB,cAAc;AAE7C,WAAO,0BAA0B,MAAM,OAAO,uBAAuB,CAAC,CAAC,EAAE,QAAQ,OAAO,uBAAuB,CAAC;AAAA,EAClH,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,11 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { parseJsonOrYaml } from "../../helpers/parse.js";
3
- import baseDefinition from "@/spec-extentions/x-scalar-environments.yaml?raw";
4
- import { xScalarSecretsSchema } from "./x-scalar-secrets.js";
5
- describe("x-scalar-secrets", () => {
6
- it("Handles spec definition", () => {
7
- const parsed = parseJsonOrYaml(baseDefinition);
8
- expect(xScalarSecretsSchema.parse(parsed["x-scalar-secrets"])).toEqual(parsed["x-scalar-secrets"]);
9
- });
10
- });
11
- //# sourceMappingURL=x-scalar-secrets.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/entities/spec/x-scalar-secrets.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { parseJsonOrYaml } from '@/helpers/parse'\nimport baseDefinition from '@/spec-extentions/x-scalar-environments.yaml?raw'\nimport { xScalarSecretsSchema } from './x-scalar-secrets'\n\ndescribe('x-scalar-secrets', () => {\n it('Handles spec definition', () => {\n const parsed = parseJsonOrYaml(baseDefinition)\n\n expect(xScalarSecretsSchema.parse(parsed['x-scalar-secrets'])).toEqual(parsed['x-scalar-secrets'])\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,uBAAuB;AAChC,OAAO,oBAAoB;AAC3B,SAAS,4BAA4B;AAErC,SAAS,oBAAoB,MAAM;AACjC,KAAG,2BAA2B,MAAM;AAClC,UAAM,SAAS,gBAAgB,cAAc;AAE7C,WAAO,qBAAqB,MAAM,OAAO,kBAAkB,CAAC,CAAC,EAAE,QAAQ,OAAO,kBAAkB,CAAC;AAAA,EACnG,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,70 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { ensureProtocol } from "./ensure-protocol.js";
3
- describe("ensureProtocol", () => {
4
- describe("URLs with existing protocols", () => {
5
- it("preserves http protocol", () => {
6
- expect(ensureProtocol("http://example.com")).toBe("http://example.com");
7
- });
8
- it("preserves https protocol", () => {
9
- expect(ensureProtocol("https://example.com")).toBe("https://example.com");
10
- });
11
- it("preserves ws protocol", () => {
12
- expect(ensureProtocol("ws://example.com")).toBe("ws://example.com");
13
- });
14
- it("preserves wss protocol", () => {
15
- expect(ensureProtocol("wss://example.com")).toBe("wss://example.com");
16
- });
17
- it("preserves file protocol", () => {
18
- expect(ensureProtocol("file:///path/to/file")).toBe("file:///path/to/file");
19
- });
20
- });
21
- describe("URLs without protocols", () => {
22
- it("adds http protocol to domain", () => {
23
- expect(ensureProtocol("example.com")).toBe("http://example.com");
24
- });
25
- it("adds http protocol to domain with path", () => {
26
- expect(ensureProtocol("example.com/path")).toBe("http://example.com/path");
27
- });
28
- it("adds http protocol to domain with query", () => {
29
- expect(ensureProtocol("example.com?query=1")).toBe("http://example.com?query=1");
30
- });
31
- it("adds http protocol to domain with port", () => {
32
- expect(ensureProtocol("example.com:8080")).toBe("http://example.com:8080");
33
- });
34
- it("adds http protocol to localhost", () => {
35
- expect(ensureProtocol("localhost:3000")).toBe("http://localhost:3000");
36
- });
37
- });
38
- describe("template variables", () => {
39
- it("prepends http:// to template variables", () => {
40
- expect(ensureProtocol("{protocol}://example.com")).toBe("http://{protocol}://example.com");
41
- });
42
- it("preserves path templates", () => {
43
- expect(ensureProtocol("/api/{version}")).toBe("http://api/{version}");
44
- });
45
- it("prepends http:// to full URL templates", () => {
46
- expect(ensureProtocol("{protocol}://{host}/{path}")).toBe("http://{protocol}://{host}/{path}");
47
- });
48
- });
49
- describe("edge cases", () => {
50
- it("handles empty string", () => {
51
- expect(ensureProtocol("")).toBe("http://");
52
- });
53
- it("prepends http:// to invalid URLs", () => {
54
- expect(ensureProtocol("not://valid")).toBe("http://not://valid");
55
- });
56
- it("handles URLs with authentication", () => {
57
- expect(ensureProtocol("user:pass@example.com")).toBe("http://user:pass@example.com");
58
- });
59
- it("handles IP addresses", () => {
60
- expect(ensureProtocol("127.0.0.1")).toBe("http://127.0.0.1");
61
- });
62
- it("handles IPv6 addresses", () => {
63
- expect(ensureProtocol("[::1]")).toBe("http://[::1]");
64
- });
65
- it("handles URLs with fragments", () => {
66
- expect(ensureProtocol("example.com#section")).toBe("http://example.com#section");
67
- });
68
- });
69
- });
70
- //# sourceMappingURL=ensure-protocol.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers/ensure-protocol.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { ensureProtocol } from './ensure-protocol'\n\ndescribe('ensureProtocol', () => {\n describe('URLs with existing protocols', () => {\n it('preserves http protocol', () => {\n expect(ensureProtocol('http://example.com')).toBe('http://example.com')\n })\n\n it('preserves https protocol', () => {\n expect(ensureProtocol('https://example.com')).toBe('https://example.com')\n })\n\n it('preserves ws protocol', () => {\n expect(ensureProtocol('ws://example.com')).toBe('ws://example.com')\n })\n\n it('preserves wss protocol', () => {\n expect(ensureProtocol('wss://example.com')).toBe('wss://example.com')\n })\n\n it('preserves file protocol', () => {\n expect(ensureProtocol('file:///path/to/file')).toBe('file:///path/to/file')\n })\n })\n\n describe('URLs without protocols', () => {\n it('adds http protocol to domain', () => {\n expect(ensureProtocol('example.com')).toBe('http://example.com')\n })\n\n it('adds http protocol to domain with path', () => {\n expect(ensureProtocol('example.com/path')).toBe('http://example.com/path')\n })\n\n it('adds http protocol to domain with query', () => {\n expect(ensureProtocol('example.com?query=1')).toBe('http://example.com?query=1')\n })\n\n it('adds http protocol to domain with port', () => {\n expect(ensureProtocol('example.com:8080')).toBe('http://example.com:8080')\n })\n\n it('adds http protocol to localhost', () => {\n expect(ensureProtocol('localhost:3000')).toBe('http://localhost:3000')\n })\n })\n\n describe('template variables', () => {\n it('prepends http:// to template variables', () => {\n expect(ensureProtocol('{protocol}://example.com')).toBe('http://{protocol}://example.com')\n })\n\n it('preserves path templates', () => {\n expect(ensureProtocol('/api/{version}')).toBe('http://api/{version}')\n })\n\n it('prepends http:// to full URL templates', () => {\n expect(ensureProtocol('{protocol}://{host}/{path}')).toBe('http://{protocol}://{host}/{path}')\n })\n })\n\n describe('edge cases', () => {\n it('handles empty string', () => {\n expect(ensureProtocol('')).toBe('http://')\n })\n\n it('prepends http:// to invalid URLs', () => {\n expect(ensureProtocol('not://valid')).toBe('http://not://valid')\n })\n\n it('handles URLs with authentication', () => {\n expect(ensureProtocol('user:pass@example.com')).toBe('http://user:pass@example.com')\n })\n\n it('handles IP addresses', () => {\n expect(ensureProtocol('127.0.0.1')).toBe('http://127.0.0.1')\n })\n\n it('handles IPv6 addresses', () => {\n expect(ensureProtocol('[::1]')).toBe('http://[::1]')\n })\n\n it('handles URLs with fragments', () => {\n expect(ensureProtocol('example.com#section')).toBe('http://example.com#section')\n })\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,sBAAsB;AAE/B,SAAS,kBAAkB,MAAM;AAC/B,WAAS,gCAAgC,MAAM;AAC7C,OAAG,2BAA2B,MAAM;AAClC,aAAO,eAAe,oBAAo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O,eAAe,4BAA4B,CAAC,EAAE,KAAK,mCAAmC;AAAA,IAC/F,CAAC;AAAA,EACH,CAAC;AAED,WAAS,cAAc,MAAM;AAC3B,OAAG,wBAAwB,MAAM;AAC/B,aAAO,eAAe,EAAE,CAAC,EAAE,KAAK,SAAS;AAAA,IAC3C,CAAC;AAED,OAAG,oCAAoC,MAAM;AAC3C,aAAO,eAAe,aAAa,CAAC,EAAE,KAAK,oBAAoB;AAAA,IACjE,CAAC;AAED,OAAG,oCAAoC,MAAM;AAC3C,aAAO,eAAe,uBAAuB,CAAC,EAAE,KAAK,8BAA8B;AAAA,IACrF,CAAC;AAED,OAAG,wBAAwB,MAAM;AAC/B,aAAO,eAAe,WAAW,CAAC,EAAE,KAAK,kBAAkB;AAAA,IAC7D,CAAC;AAED,OAAG,0BAA0B,MAAM;AACjC,aAAO,eAAe,OAAO,CAAC,EAAE,KAAK,cAAc;AAAA,IACrD,CAAC;AAED,OAAG,+BAA+B,MAAM;AACtC,aAAO,eAAe,qBAAqB,CAAC,EAAE,KAAK,4BAA4B;AAAA,IACjF,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,63 +0,0 @@
1
- import { beforeAll, describe, expect, it, vi } from "vitest";
2
- import { fetchDocument } from "./fetch-document.js";
3
- const PROXY_PORT = 5051;
4
- beforeAll(async () => {
5
- try {
6
- const result = await fetch(`http://127.0.0.1:${PROXY_PORT}`);
7
- if (result.ok) {
8
- return;
9
- }
10
- } catch (_error) {
11
- throw new Error(`
12
-
13
- [sendRequest.test.ts] Looks like you\u2019re not running @scalar/proxy-server on <http://127.0.0.1:${PROXY_PORT}>, but it\u2019s required for this test file.
14
-
15
- Try to run it like this:
16
-
17
- $ pnpm dev:proxy-server
18
- `);
19
- }
20
- });
21
- describe("fetchDocument", () => {
22
- it("fetches specifications (without a proxy)", async () => {
23
- const spec = await fetchDocument("https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.yaml");
24
- expect(typeof spec).toEqual("string");
25
- expect(spec.length).toBeGreaterThan(100);
26
- });
27
- it("fetches specifications (through proxy.scalar.com)", async () => {
28
- const spec = await fetchDocument(
29
- "https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.yaml",
30
- "https://proxy.scalar.com"
31
- );
32
- expect(typeof spec).toEqual("string");
33
- expect(spec.length).toBeGreaterThan(100);
34
- });
35
- it(`fetches specifications (through 127.0.0.1:${PROXY_PORT})`, async () => {
36
- const spec = await fetchDocument(
37
- "https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.yaml",
38
- `http://127.0.0.1:${PROXY_PORT}`
39
- );
40
- expect(typeof spec).toEqual("string");
41
- expect(spec.length).toBeGreaterThan(100);
42
- });
43
- it("fetches specifications from localhost without proxy", async () => {
44
- const originalFetch = globalThis.fetch;
45
- globalThis.fetch = vi.fn(
46
- () => Promise.resolve({
47
- ok: true,
48
- status: 200,
49
- text: () => Promise.resolve("")
50
- })
51
- );
52
- const spec = await fetchDocument(`http://127.0.0.1:${PROXY_PORT}/test`);
53
- expect(typeof spec).toEqual("string");
54
- globalThis.fetch = originalFetch;
55
- });
56
- it("throws error for invalid URLs", async () => {
57
- await expect(fetchDocument("not-a-valid-url")).rejects.toThrow();
58
- });
59
- it("throws error when fetch fails", async () => {
60
- await expect(fetchDocument("https://does-not-exist.scalar.com/spec.yaml")).rejects.toThrow("fetch failed");
61
- });
62
- });
63
- //# sourceMappingURL=fetch-document.test.js.map