@scalar/oas-utils 0.4.21 → 0.4.23
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.
- package/CHANGELOG.md +40 -0
- package/dist/entities/spec/collection.d.ts.map +1 -1
- package/dist/entities/spec/request-examples.d.ts +65 -65
- package/dist/entities/spec/request-examples.d.ts.map +1 -1
- package/dist/entities/spec/requests.d.ts +3 -3
- package/dist/entities/spec/requests.d.ts.map +1 -1
- package/dist/entities/spec/spec-objects.d.ts.map +1 -1
- package/dist/helpers/fetch-document.d.ts +1 -1
- package/dist/helpers/fetch-document.d.ts.map +1 -1
- package/dist/helpers/fetch-document.js +2 -2
- package/dist/helpers/fetch-document.js.map +2 -2
- package/dist/helpers/normalize-mime-type-object.d.ts +1 -1
- package/dist/helpers/normalize-mime-type-object.d.ts.map +1 -1
- package/dist/helpers/normalize-mime-type-object.js.map +1 -1
- package/dist/helpers/operation-stability.d.ts.map +1 -1
- package/dist/helpers/operation-to-har/operation-to-har.d.ts +1 -3
- package/dist/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
- package/dist/helpers/operation-to-har/operation-to-har.js.map +2 -2
- package/dist/helpers/operation-to-har/process-body.d.ts +2 -2
- package/dist/helpers/operation-to-har/process-body.d.ts.map +1 -1
- package/dist/helpers/operation-to-har/process-body.js +18 -1
- package/dist/helpers/operation-to-har/process-body.js.map +2 -2
- package/dist/helpers/operation-to-har/process-parameters.d.ts +1 -2
- package/dist/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
- package/dist/helpers/operation-to-har/process-parameters.js.map +2 -2
- package/dist/helpers/operation-to-har/process-security-schemes.d.ts +1 -1
- package/dist/helpers/operation-to-har/process-security-schemes.d.ts.map +1 -1
- package/dist/helpers/operation-to-har/process-security-schemes.js +2 -1
- package/dist/helpers/operation-to-har/process-security-schemes.js.map +2 -2
- package/dist/helpers/operation-to-har/process-server-url.d.ts +1 -1
- package/dist/helpers/operation-to-har/process-server-url.d.ts.map +1 -1
- package/dist/helpers/operation-to-har/process-server-url.js.map +1 -1
- package/dist/helpers/parse.d.ts.map +1 -1
- package/dist/helpers/pretty-print-json.d.ts.map +1 -1
- package/dist/helpers/security/get-schemes.d.ts.map +1 -1
- package/dist/helpers/security/has-token.d.ts.map +1 -1
- package/dist/helpers/servers.d.ts +1 -1
- package/dist/helpers/servers.d.ts.map +1 -1
- package/dist/helpers/servers.js.map +1 -1
- package/dist/helpers/should-ignore-entity.d.ts.map +1 -1
- package/dist/migrations/local-storage.d.ts.map +1 -1
- package/dist/migrations/semver.d.ts.map +1 -1
- package/dist/migrations/v-2.1.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.2.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.3.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.4.0/migration.d.ts.map +1 -1
- package/dist/migrations/v-2.5.0/migration.d.ts.map +1 -1
- package/dist/spec-getters/get-example-from-schema.d.ts +3 -3
- package/dist/spec-getters/get-example-from-schema.d.ts.map +1 -1
- package/dist/spec-getters/get-example-from-schema.js +55 -53
- package/dist/spec-getters/get-example-from-schema.js.map +2 -2
- package/dist/spec-getters/get-parameters-from-operation.d.ts.map +1 -1
- package/dist/spec-getters/get-parameters-from-operation.js +1 -4
- package/dist/spec-getters/get-parameters-from-operation.js.map +2 -2
- package/dist/spec-getters/get-request-body-from-operation.js +1 -1
- package/dist/spec-getters/get-request-body-from-operation.js.map +2 -2
- package/dist/spec-getters/get-server-variable-examples.d.ts.map +1 -1
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/package.json +10 -9
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/servers.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Server, serverSchema } from '@/entities/spec/server'\nimport { isDefined } from '@scalar/helpers/array/is-defined'\nimport { combineUrlAndPath } from '@scalar/helpers/url/merge-urls'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/
|
|
4
|
+
"sourcesContent": ["import { type Server, serverSchema } from '@/entities/spec/server'\nimport { isDefined } from '@scalar/helpers/array/is-defined'\nimport { combineUrlAndPath } from '@scalar/helpers/url/merge-urls'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\n/**\n * Server processing options containing base URLs for resolving relative server URLs.\n */\ntype ServerProcessingOptions = {\n baseServerURL?: string\n documentUrl?: string\n}\n\n/**\n * Retrieves and processes servers from an OpenAPI document.\n *\n * This function handles several scenarios:\n * 1. No servers provided - creates a default server from document URL or fallback\n * 2. Invalid server configurations - filters them out with warnings\n * 3. Relative URLs - resolves them to absolute URLs using available base URLs\n *\n * @param servers - Array of OpenAPI server objects from the document\n * @param options - Configuration options for server processing\n * @returns Array of validated Server entities\n */\nexport function getServersFromDocument(\n servers: ServerObject[] | undefined,\n options: ServerProcessingOptions = {},\n): Server[] {\n // Handle case where no servers are provided\n if (!servers?.length) {\n const fallbackServer = createFallbackServer(options)\n return fallbackServer ? [fallbackServer] : []\n }\n\n // Handle invalid server array\n if (!Array.isArray(servers)) {\n return []\n }\n\n // Process each server and filter out invalid ones\n const validServers = servers.map((server) => processServerObject(server, options)).filter(isDefined)\n\n // If all servers were invalid, provide a fallback\n if (validServers.length === 0) {\n const fallbackServer = createFallbackServer(options)\n return fallbackServer ? [fallbackServer] : []\n }\n\n return validServers\n}\n\n/**\n * Extracts the base URL (protocol + hostname) from a document URL.\n * Returns undefined if the URL is invalid.\n */\nfunction extractBaseUrlFromDocumentUrl(documentUrl: string): string | undefined {\n try {\n const url = new URL(documentUrl)\n const port = url.port ? `:${url.port}` : ''\n return `${url.protocol}//${url.hostname}${port}`\n } catch {\n return undefined\n }\n}\n\n/**\n * Gets the fallback URL from window.location.origin if available.\n */\nfunction getFallbackUrl(): string | undefined {\n if (typeof window === 'undefined' || typeof window?.location?.origin !== 'string') {\n return undefined\n }\n return window.location.origin\n}\n\n/**\n * Creates a server object from a URL string, with error handling.\n */\nfunction createServerFromUrl(url: string, context: string): Server | undefined {\n try {\n return serverSchema.parse({ url })\n } catch {\n console.warn(`Failed to create server from ${context}:`, url)\n return undefined\n }\n}\n\n/**\n * Creates a default server using the document URL as the base.\n */\nfunction createDefaultServerFromDocumentUrl(documentUrl: string): Server | undefined {\n const baseUrl = extractBaseUrlFromDocumentUrl(documentUrl)\n if (!baseUrl) {\n return undefined\n }\n\n return createServerFromUrl(baseUrl, 'document URL')\n}\n\n/**\n * Creates a default server using the fallback URL (window.location.origin).\n */\nfunction createDefaultServerFromFallback(): Server | undefined {\n const fallbackUrl = getFallbackUrl()\n if (!fallbackUrl) {\n return undefined\n }\n\n return createServerFromUrl(fallbackUrl, 'fallback URL')\n}\n\n/**\n * Resolves a relative server URL to an absolute URL using available base URLs.\n * Uses a priority system: baseServerURL > documentUrl > fallbackUrl.\n */\nfunction resolveRelativeServerUrl(serverUrl: string, options: ServerProcessingOptions): string {\n const { baseServerURL, documentUrl } = options\n\n // Priority 1: Use provided base server URL\n if (baseServerURL) {\n return combineUrlAndPath(baseServerURL, serverUrl)\n }\n\n // Priority 2: Extract base URL from document URL\n if (documentUrl) {\n const baseUrl = extractBaseUrlFromDocumentUrl(documentUrl)\n if (baseUrl) {\n return combineUrlAndPath(baseUrl, serverUrl)\n }\n }\n\n // Priority 3: Use fallback URL (window.location.origin)\n const fallbackUrl = getFallbackUrl()\n if (fallbackUrl) {\n return combineUrlAndPath(fallbackUrl, serverUrl)\n }\n\n // If no base URL is available, return the original URL\n return serverUrl\n}\n\n/**\n * Processes a single server object, handling validation and URL resolution.\n */\nfunction processServerObject(server: ServerObject, options: ServerProcessingOptions): Server | undefined {\n try {\n const parsedServer = serverSchema.parse(server)\n\n // Resolve relative URLs to absolute URLs\n if (parsedServer.url?.startsWith('/')) {\n parsedServer.url = resolveRelativeServerUrl(parsedServer.url, options)\n }\n\n return parsedServer\n } catch (error) {\n console.warn('Invalid server configuration:', server, 'Error:', error)\n return undefined\n }\n}\n\n/**\n * Creates a fallback server when no valid servers are available.\n * Uses document URL first, then fallback URL.\n */\nfunction createFallbackServer(options: ServerProcessingOptions): Server | undefined {\n // Priority 1: Try to create default server from document URL\n if (options.documentUrl) {\n const defaultServer = createDefaultServerFromDocumentUrl(options.documentUrl)\n\n if (defaultServer) {\n return defaultServer\n }\n }\n\n // Priority 2: Try to create default server from fallback URL\n return createDefaultServerFromFallback()\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAsB,oBAAoB;AAC1C,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAuB3B,SAAS,uBACd,SACA,UAAmC,CAAC,GAC1B;AAEV,MAAI,CAAC,SAAS,QAAQ;AACpB,UAAM,iBAAiB,qBAAqB,OAAO;AACnD,WAAO,iBAAiB,CAAC,cAAc,IAAI,CAAC;AAAA,EAC9C;AAGA,MAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;AAC3B,WAAO,CAAC;AAAA,EACV;AAGA,QAAM,eAAe,QAAQ,IAAI,CAAC,WAAW,oBAAoB,QAAQ,OAAO,CAAC,EAAE,OAAO,SAAS;AAGnG,MAAI,aAAa,WAAW,GAAG;AAC7B,UAAM,iBAAiB,qBAAqB,OAAO;AACnD,WAAO,iBAAiB,CAAC,cAAc,IAAI,CAAC;AAAA,EAC9C;AAEA,SAAO;AACT;AAMA,SAAS,8BAA8B,aAAyC;AAC9E,MAAI;AACF,UAAM,MAAM,IAAI,IAAI,WAAW;AAC/B,UAAM,OAAO,IAAI,OAAO,IAAI,IAAI,IAAI,KAAK;AACzC,WAAO,GAAG,IAAI,QAAQ,KAAK,IAAI,QAAQ,GAAG,IAAI;AAAA,EAChD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAKA,SAAS,iBAAqC;AAC5C,MAAI,OAAO,WAAW,eAAe,OAAO,QAAQ,UAAU,WAAW,UAAU;AACjF,WAAO;AAAA,EACT;AACA,SAAO,OAAO,SAAS;AACzB;AAKA,SAAS,oBAAoB,K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ACF;AAGA,SAAO,gCAAgC;AACzC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-ignore-entity.d.ts","sourceRoot":"","sources":["../../src/helpers/should-ignore-entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAA;AAEvD;;GAEG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"should-ignore-entity.d.ts","sourceRoot":"","sources":["../../src/helpers/should-ignore-entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAA;AAEvD;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MACI,SAAS,GACT,IAAI,CAAC,GAAG,EAAE,YAAY,GAAG,iBAAiB,CAAC,GAC3C,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,iBAAiB,CAAC,GAC/C,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,iBAAiB,CAAC,YAGpD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/migrations/local-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAMnE;;GAEG;AACH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/migrations/local-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAMnE;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,CAAC,OAAO,OAAO,EAAE,MAAM,OAAO,OAAO,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAKvG,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,sBAAsB,QAAO,MAyBzC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semver.d.ts","sourceRoot":"","sources":["../../src/migrations/semver.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"semver.d.ts","sourceRoot":"","sources":["../../src/migrations/semver.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,OAyB5D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.1.0/migration.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,mCAAmC;AACnC,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.1.0/migration.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,mCAAmC;AACnC,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC;;;;;;;;;;CA0UxE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.2.0/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAkGhD,mCAAmC;AACnC,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.2.0/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAkGhD,mCAAmC;AACnC,eAAO,MAAM,eAAe,GAAI,MAAM,OAAO,CAAC,UAAU,KAAG,OAAO,CAAC,UA6BlE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.3.0/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,mCAAmC;AACnC,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.3.0/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,mCAAmC;AACnC,eAAO,MAAM,eAAe,GAAI,MAAM,OAAO,CAAC,UAAU,KAAG,OAAO,CAAC,UAqDlE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.4.0/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,mCAAmC;AACnC,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.4.0/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,mCAAmC;AACnC,eAAO,MAAM,eAAe,GAAI,MAAM,OAAO,CAAC,UAAU,KAAG,OAAO,CAAC,UA6BlE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.5.0/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,mCAAmC;AACnC,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.5.0/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,mCAAmC;AACnC,eAAO,MAAM,eAAe,GAAI,MAAM,OAAO,CAAC,UAAU,KAAG,OAAO,CAAC,YAAY,CAkK9E,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
2
2
|
/**
|
|
3
3
|
* This function takes an OpenAPI schema and generates an example from it
|
|
4
4
|
*/
|
|
5
|
-
export declare const getExampleFromSchema: (_schema: SchemaObject, options?: {
|
|
5
|
+
export declare const getExampleFromSchema: (_schema: OpenAPIV3_1.SchemaObject, options?: {
|
|
6
6
|
/**
|
|
7
7
|
* The fallback string for empty string values.
|
|
8
8
|
* @default ''
|
|
@@ -27,5 +27,5 @@ export declare const getExampleFromSchema: (_schema: SchemaObject, options?: {
|
|
|
27
27
|
* @default false
|
|
28
28
|
*/
|
|
29
29
|
omitEmptyAndOptionalProperties?: boolean;
|
|
30
|
-
}, level?: number, parentSchema?: SchemaObject, name?: string) => any;
|
|
30
|
+
}, level?: number, parentSchema?: OpenAPIV3_1.SchemaObject, name?: string) => any;
|
|
31
31
|
//# sourceMappingURL=get-example-from-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../src/spec-getters/get-example-from-schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../src/spec-getters/get-example-from-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAwExD;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,WAAW,CAAC,YAAY,EACjC,UAAU;IACR;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B;;;OAGG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAA;CACzC,EACD,QAAO,MAAU,EACjB,eAAe,WAAW,CAAC,YAAY,EACvC,OAAO,MAAM,KACZ,GAyTF,CAAA"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { isDefined } from "@scalar/helpers/array/is-defined";
|
|
2
2
|
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
3
|
-
const MAX_LEVELS_DEEP =
|
|
3
|
+
const MAX_LEVELS_DEEP = 10;
|
|
4
4
|
const MAX_PROPERTIES = 10;
|
|
5
5
|
const DEFAULT_ADDITIONAL_PROPERTIES_NAME = "propertyName*";
|
|
6
|
+
const currentISOString = (/* @__PURE__ */ new Date()).toISOString();
|
|
7
|
+
const currentDateString = currentISOString.split("T")[0];
|
|
8
|
+
const currentTimeString = currentISOString.split("T")[1].split(".")[0];
|
|
6
9
|
const genericExampleValues = {
|
|
7
10
|
// 'date-time': '1970-01-01T00:00:00Z',
|
|
8
|
-
"date-time":
|
|
11
|
+
"date-time": currentISOString,
|
|
9
12
|
// 'date': '1970-01-01',
|
|
10
|
-
"date":
|
|
13
|
+
"date": currentDateString,
|
|
11
14
|
"email": "hello@example.com",
|
|
12
15
|
"hostname": "example.com",
|
|
13
16
|
// https://tools.ietf.org/html/rfc6531#section-3.3
|
|
@@ -26,7 +29,7 @@ const genericExampleValues = {
|
|
|
26
29
|
"relative-json-pointer": "1/nested/objects",
|
|
27
30
|
// full-time in https://tools.ietf.org/html/rfc3339#section-5.6
|
|
28
31
|
// 'time': '00:00:00Z',
|
|
29
|
-
"time":
|
|
32
|
+
"time": currentTimeString,
|
|
30
33
|
// either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1
|
|
31
34
|
"uri-reference": "../folder",
|
|
32
35
|
"uri-template": "https://example.com/{id}",
|
|
@@ -50,15 +53,14 @@ function cache(schema, result) {
|
|
|
50
53
|
}
|
|
51
54
|
const getExampleFromSchema = (_schema, options, level = 0, parentSchema, name) => {
|
|
52
55
|
const schema = getResolvedRef(_schema);
|
|
56
|
+
if (!isDefined(schema)) {
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
53
59
|
if (resultCache.has(schema)) {
|
|
54
60
|
return resultCache.get(schema);
|
|
55
61
|
}
|
|
56
|
-
if (level
|
|
57
|
-
|
|
58
|
-
JSON.stringify(schema);
|
|
59
|
-
} catch {
|
|
60
|
-
return "[Circular Reference]";
|
|
61
|
-
}
|
|
62
|
+
if (level > MAX_LEVELS_DEEP) {
|
|
63
|
+
return "[Max Depth Exceeded]";
|
|
62
64
|
}
|
|
63
65
|
const makeUpRandomData = !!options?.emptyString;
|
|
64
66
|
if (schema.deprecated) {
|
|
@@ -71,7 +73,8 @@ const getExampleFromSchema = (_schema, options, level = 0, parentSchema, name) =
|
|
|
71
73
|
const value = options?.variables?.[schema["x-variable"]];
|
|
72
74
|
if (value !== void 0) {
|
|
73
75
|
if (schema.type === "number" || schema.type === "integer") {
|
|
74
|
-
|
|
76
|
+
const numValue = Number.parseInt(value, 10);
|
|
77
|
+
return cache(schema, numValue);
|
|
75
78
|
}
|
|
76
79
|
return cache(schema, value);
|
|
77
80
|
}
|
|
@@ -93,11 +96,7 @@ const getExampleFromSchema = (_schema, options, level = 0, parentSchema, name) =
|
|
|
93
96
|
}
|
|
94
97
|
const isObjectOrArray = schema.type === "object" || schema.type === "array" || !!schema.allOf?.at?.(0) || !!schema.anyOf?.at?.(0) || !!schema.oneOf?.at?.(0);
|
|
95
98
|
if (!isObjectOrArray && options?.omitEmptyAndOptionalProperties === true) {
|
|
96
|
-
const isRequired = (
|
|
97
|
-
// @ts-expect-error - I suppose old schema used to allow `required: true` remove when moving to new store
|
|
98
|
-
schema.required === true || // @ts-expect-error - I suppose old schema used to allow `required: true` remove when moving to new store
|
|
99
|
-
parentSchema?.required === true || parentSchema?.required?.includes(name ?? schema.title ?? "")
|
|
100
|
-
);
|
|
99
|
+
const isRequired = schema.required === true || parentSchema?.required === true || parentSchema?.required?.includes(name ?? schema.title ?? "");
|
|
101
100
|
if (!isRequired) {
|
|
102
101
|
return void 0;
|
|
103
102
|
}
|
|
@@ -106,35 +105,31 @@ const getExampleFromSchema = (_schema, options, level = 0, parentSchema, name) =
|
|
|
106
105
|
const response = {};
|
|
107
106
|
let propertyCount = 0;
|
|
108
107
|
if (schema.properties !== void 0) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const property = getResolvedRef(schema.properties[propertyName]);
|
|
116
|
-
const propertyXmlTagName = options?.xml ? property?.xml?.name : void 0;
|
|
117
|
-
if (!property) {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
const value = getExampleFromSchema(property, options, level + 1, schema, propertyName);
|
|
121
|
-
if (typeof value !== "undefined") {
|
|
122
|
-
response[propertyXmlTagName ?? propertyName] = value;
|
|
123
|
-
propertyCount++;
|
|
124
|
-
}
|
|
108
|
+
const propertyNames = Object.keys(schema.properties);
|
|
109
|
+
const maxProps = level > 3 ? MAX_PROPERTIES : propertyNames.length;
|
|
110
|
+
for (const propertyName of propertyNames.slice(0, maxProps)) {
|
|
111
|
+
const property = getResolvedRef(schema.properties[propertyName]);
|
|
112
|
+
if (!property) {
|
|
113
|
+
continue;
|
|
125
114
|
}
|
|
115
|
+
const propertyXmlTagName = options?.xml ? property?.xml?.name : void 0;
|
|
116
|
+
const value = getExampleFromSchema(property, options, level + 1, schema, propertyName);
|
|
117
|
+
if (typeof value !== "undefined") {
|
|
118
|
+
response[propertyXmlTagName ?? propertyName] = value;
|
|
119
|
+
propertyCount++;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (level > 3 && propertyCount >= MAX_PROPERTIES && propertyNames.length > MAX_PROPERTIES) {
|
|
123
|
+
response["..."] = "[Additional Properties Truncated]";
|
|
126
124
|
}
|
|
127
125
|
}
|
|
128
126
|
if (schema.patternProperties !== void 0) {
|
|
129
|
-
for (const pattern
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
const exampleKey = pattern;
|
|
136
|
-
response[exampleKey] = getExampleFromSchema(property, options, level + 1, schema, exampleKey);
|
|
127
|
+
for (const pattern of Object.keys(schema.patternProperties)) {
|
|
128
|
+
const property = getResolvedRef(schema.patternProperties[pattern]);
|
|
129
|
+
if (!property) {
|
|
130
|
+
continue;
|
|
137
131
|
}
|
|
132
|
+
response[pattern] = getExampleFromSchema(property, options, level + 1, schema, pattern);
|
|
138
133
|
}
|
|
139
134
|
}
|
|
140
135
|
if (schema.additionalProperties !== void 0) {
|
|
@@ -161,6 +156,11 @@ const getExampleFromSchema = (_schema, options, level = 0, parentSchema, name) =
|
|
|
161
156
|
...schema.allOf.filter(isDefined).map((item) => getExampleFromSchema(getResolvedRef(item), options, level + 1, schema))
|
|
162
157
|
);
|
|
163
158
|
}
|
|
159
|
+
if (options?.xml && schema.xml?.name && level === 0) {
|
|
160
|
+
const wrappedResponse = {};
|
|
161
|
+
wrappedResponse[schema.xml.name] = response;
|
|
162
|
+
return cache(schema, wrappedResponse);
|
|
163
|
+
}
|
|
164
164
|
return cache(schema, response);
|
|
165
165
|
}
|
|
166
166
|
if (schema.type === "array" || schema.items !== void 0) {
|
|
@@ -182,23 +182,24 @@ const getExampleFromSchema = (_schema, options, level = 0, parentSchema, name) =
|
|
|
182
182
|
const examples = allOf.map((item) => getExampleFromSchema(getResolvedRef(item), options, level + 1, schema)).filter(isDefined);
|
|
183
183
|
return cache(schema, wrapItems ? examples.map((example) => ({ [itemsXmlTagName]: example })) : examples);
|
|
184
184
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (
|
|
188
|
-
|
|
185
|
+
if (items.anyOf || items.oneOf) {
|
|
186
|
+
const ruleItems = items.anyOf || items.oneOf;
|
|
187
|
+
if (ruleItems && ruleItems.length > 0) {
|
|
188
|
+
const firstItem = ruleItems[0];
|
|
189
|
+
if (firstItem) {
|
|
190
|
+
const exampleFromRule = getExampleFromSchema(getResolvedRef(firstItem), options, level + 1, schema);
|
|
191
|
+
return cache(schema, wrapItems ? [{ [itemsXmlTagName]: exampleFromRule }] : [exampleFromRule]);
|
|
192
|
+
}
|
|
189
193
|
}
|
|
190
|
-
const schemas = items[rule].slice(0, 1);
|
|
191
|
-
const exampleFromRule = schemas.map((item) => getExampleFromSchema(getResolvedRef(item), options, level + 1, schema)).filter(isDefined);
|
|
192
|
-
return cache(schema, wrapItems ? [{ [itemsXmlTagName]: exampleFromRule }] : exampleFromRule);
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
const isObject = items?.type === "object" || items?.properties !== void 0;
|
|
196
197
|
const isArray = items?.type === "array" || items?.items !== void 0;
|
|
197
198
|
if (items?.type || isObject || isArray) {
|
|
198
199
|
const exampleFromSchema = getExampleFromSchema(items, options, level + 1);
|
|
199
|
-
return wrapItems ? [{ [itemsXmlTagName]: exampleFromSchema }] : [exampleFromSchema];
|
|
200
|
+
return cache(schema, wrapItems ? [{ [itemsXmlTagName]: exampleFromSchema }] : [exampleFromSchema]);
|
|
200
201
|
}
|
|
201
|
-
return [];
|
|
202
|
+
return cache(schema, []);
|
|
202
203
|
}
|
|
203
204
|
const exampleValues = {
|
|
204
205
|
string: guessFromFormat(schema, makeUpRandomData, options?.emptyString),
|
|
@@ -214,9 +215,10 @@ const getExampleFromSchema = (_schema, options, level = 0, parentSchema, name) =
|
|
|
214
215
|
if (Array.isArray(discriminateSchema) && discriminateSchema.length > 0) {
|
|
215
216
|
const firstNonNullItem = discriminateSchema.map((item) => getResolvedRef(item)).find((item) => item.type !== "null");
|
|
216
217
|
if (firstNonNullItem) {
|
|
217
|
-
|
|
218
|
+
const result = getExampleFromSchema(firstNonNullItem, options, level + 1);
|
|
219
|
+
return cache(schema, result);
|
|
218
220
|
}
|
|
219
|
-
return null;
|
|
221
|
+
return cache(schema, null);
|
|
220
222
|
}
|
|
221
223
|
if (Array.isArray(schema.allOf)) {
|
|
222
224
|
let example = null;
|
|
@@ -231,14 +233,14 @@ const getExampleFromSchema = (_schema, options, level = 0, parentSchema, name) =
|
|
|
231
233
|
}
|
|
232
234
|
if (Array.isArray(schema.type)) {
|
|
233
235
|
if (schema.type.includes("null")) {
|
|
234
|
-
return null;
|
|
236
|
+
return cache(schema, null);
|
|
235
237
|
}
|
|
236
238
|
const exampleValue = exampleValues[schema.type[0] ?? ""];
|
|
237
239
|
if (exampleValue !== void 0) {
|
|
238
240
|
return cache(schema, exampleValue);
|
|
239
241
|
}
|
|
240
242
|
}
|
|
241
|
-
return null;
|
|
243
|
+
return cache(schema, null);
|
|
242
244
|
};
|
|
243
245
|
export {
|
|
244
246
|
getExampleFromSchema
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/spec-getters/get-example-from-schema.ts"],
|
|
4
|
-
"sourcesContent": ["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { SchemaObject } from '@scalar/workspace-store/schemas/v3.1/strict/schema'\n\nconst MAX_LEVELS_DEEP = 5\n/** Sets the max number of properties after the third level to prevent exponential horizontal growth */\nconst MAX_PROPERTIES = 10\n\n/** The default name for additional properties. */\nconst DEFAULT_ADDITIONAL_PROPERTIES_NAME = 'propertyName*'\n\nconst genericExampleValues: Record<string, string> = {\n // 'date-time': '1970-01-01T00:00:00Z',\n 'date-time': new Date().toISOString(),\n // 'date': '1970-01-01',\n 'date': new Date().toISOString().split('T')[0]!,\n 'email': 'hello@example.com',\n 'hostname': 'example.com',\n // https://tools.ietf.org/html/rfc6531#section-3.3\n 'idn-email': 'jane.doe@example.com',\n // https://tools.ietf.org/html/rfc5890#section-2.3.2.3\n 'idn-hostname': 'example.com',\n 'ipv4': '127.0.0.1',\n 'ipv6': '51d4:7fab:bfbf:b7d7:b2cb:d4b4:3dad:d998',\n 'iri-reference': '/entitiy/1',\n // https://tools.ietf.org/html/rfc3987\n 'iri': 'https://example.com/entity/123',\n 'json-pointer': '/nested/objects',\n 'password': 'super-secret',\n 'regex': '/[a-z]/',\n // https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01\n 'relative-json-pointer': '1/nested/objects',\n // full-time in https://tools.ietf.org/html/rfc3339#section-5.6\n // 'time': '00:00:00Z',\n 'time': new Date().toISOString().split('T')[1]!.split('.')[0]!,\n // either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1\n 'uri-reference': '../folder',\n 'uri-template': 'https://example.com/{id}',\n 'uri': 'https://example.com',\n 'uuid': '123e4567-e89b-12d3-a456-426614174000',\n 'object-id': '6592008029c8c3e4dc76256c',\n}\n\n/**\n * We can use the `format` to generate some random values.\n */\nfunction guessFromFormat(schema: SchemaObject, makeUpRandomData: boolean = false, fallback: string = '') {\n if (schema.format === 'binary') {\n return new File([''], 'filename')\n }\n return makeUpRandomData ? (genericExampleValues[schema.format ?? ''] ?? fallback) : ''\n}\n\n/** Map of all the results */\nconst resultCache = new WeakMap<Record<string, any>, any>()\n\n/** Store result in the cache, and return the result */\nfunction cache(schema: SchemaObject, result: unknown) {\n // Avoid unnecessary WeakMap operations for primitive values\n if (typeof result !== 'object' || result === null) {\n return result\n }\n\n resultCache.set(schema, result)\n\n return result\n}\n\n/**\n * This function takes an OpenAPI schema and generates an example from it\n */\nexport const getExampleFromSchema = (\n _schema: SchemaObject,\n options?: {\n /**\n * The fallback string for empty string values.\n * @default ''\n */\n emptyString?: string\n /**\n * Whether to use the XML tag names as keys\n * @default false\n */\n xml?: boolean\n /**\n * Whether to show read-only/write-only properties. Otherwise all properties are shown.\n * @default undefined\n */\n mode?: 'read' | 'write'\n /**\n * Dynamic values to add to the example.\n */\n variables?: Record<string, any>\n /**\n * Whether to omit empty and optional properties.\n * @default false\n */\n omitEmptyAndOptionalProperties?: boolean\n },\n level: number = 0,\n parentSchema?: SchemaObject,\n name?: string,\n): any => {\n const schema = getResolvedRef(_schema)\n\n // Check if the result is already cached\n if (resultCache.has(schema)) {\n return resultCache.get(schema)\n }\n\n // Check whether it's a circular reference\n if (level === MAX_LEVELS_DEEP + 1) {\n try {\n // Fails if it contains a circular reference\n JSON.stringify(schema)\n } catch {\n return '[Circular Reference]'\n }\n }\n\n // Sometimes, we just want the structure and no values.\n // But if `emptyString` is set, we do want to see some values.\n const makeUpRandomData = !!options?.emptyString\n\n // If the property is deprecated anyway, we don't want to show it.\n if (schema.deprecated) {\n return undefined\n }\n\n // Check if the property is read-only/write-only\n if ((options?.mode === 'write' && schema.readOnly) || (options?.mode === 'read' && schema.writeOnly)) {\n return undefined\n }\n\n // Use given variables as values\n if (schema['x-variable']) {\n const value = options?.variables?.[schema['x-variable']]\n\n // Return the value if it's defined\n if (value !== undefined) {\n // Type-casting\n if (schema.type === 'number' || schema.type === 'integer') {\n return Number.parseInt(value, 10)\n }\n\n return cache(schema, value)\n }\n }\n\n // Use the first example, if there's an array\n if (Array.isArray(schema.examples) && schema.examples.length > 0) {\n return cache(schema, schema.examples[0])\n }\n\n // Use an example, if there's one\n if (schema.example !== undefined) {\n return cache(schema, schema.example)\n }\n\n // Use a default value, if there's one\n if (schema.default !== undefined) {\n return cache(schema, schema.default)\n }\n\n // Use a const value, if there's one\n if (schema.const !== undefined) {\n return cache(schema, schema.const)\n }\n\n // enum: [ 'available', 'pending', 'sold' ]\n if (Array.isArray(schema.enum) && schema.enum.length > 0) {\n return cache(schema, schema.enum[0])\n }\n\n // Check if the property is required\n const isObjectOrArray =\n schema.type === 'object' ||\n schema.type === 'array' ||\n !!schema.allOf?.at?.(0) ||\n !!schema.anyOf?.at?.(0) ||\n !!schema.oneOf?.at?.(0)\n if (!isObjectOrArray && options?.omitEmptyAndOptionalProperties === true) {\n const isRequired =\n // @ts-expect-error - I suppose old schema used to allow `required: true` remove when moving to new store\n schema.required === true ||\n // @ts-expect-error - I suppose old schema used to allow `required: true` remove when moving to new store\n parentSchema?.required === true ||\n parentSchema?.required?.includes(name ?? schema.title ?? '')\n\n if (!isRequired) {\n return undefined\n }\n }\n\n // Object\n if (schema.type === 'object' || schema.properties !== undefined) {\n const response: Record<string, any> = {}\n let propertyCount = 0\n\n // Regular properties\n if (schema.properties !== undefined) {\n for (const propertyName in schema.properties) {\n if (Object.prototype.hasOwnProperty.call(schema.properties, propertyName)) {\n // Only apply property limit for nested levels (level > 0)\n if (level > 3 && propertyCount >= MAX_PROPERTIES) {\n response['...'] = '[Additional Properties Truncated]'\n break\n }\n\n const property = getResolvedRef(schema.properties[propertyName])\n const propertyXmlTagName = options?.xml ? property?.xml?.name : undefined\n if (!property) {\n continue\n }\n\n const value = getExampleFromSchema(property, options, level + 1, schema, propertyName)\n\n if (typeof value !== 'undefined') {\n response[propertyXmlTagName ?? propertyName] = value\n propertyCount++\n }\n }\n }\n }\n\n // Pattern properties (regex)\n if (schema.patternProperties !== undefined) {\n for (const pattern in schema.patternProperties) {\n if (Object.prototype.hasOwnProperty.call(schema.patternProperties, pattern)) {\n const property = getResolvedRef(schema.patternProperties[pattern])\n if (!property) {\n continue\n }\n\n // Use the regex pattern as an example key\n const exampleKey = pattern\n\n response[exampleKey] = getExampleFromSchema(property, options, level + 1, schema, exampleKey)\n }\n }\n }\n\n // Additional properties\n if (schema.additionalProperties !== undefined) {\n const anyTypeIsValid =\n // true\n schema.additionalProperties === true ||\n // or an empty object {}\n (typeof schema.additionalProperties === 'object' && !Object.keys(schema.additionalProperties).length)\n\n const additionalProperties = getResolvedRef(schema.additionalProperties)\n\n // Get the custom name for additional properties if available\n const additionalPropertiesName =\n typeof additionalProperties === 'object' &&\n additionalProperties['x-additionalPropertiesName'] &&\n typeof additionalProperties['x-additionalPropertiesName'] === 'string' &&\n additionalProperties['x-additionalPropertiesName'].trim().length > 0\n ? `${additionalProperties['x-additionalPropertiesName'].trim()}*`\n : DEFAULT_ADDITIONAL_PROPERTIES_NAME\n\n if (anyTypeIsValid) {\n response[additionalPropertiesName] = 'anything'\n } else if (typeof additionalProperties === 'object') {\n response[additionalPropertiesName] = getExampleFromSchema(additionalProperties, options, level + 1)\n }\n }\n\n if (schema.anyOf?.[0]) {\n Object.assign(response, getExampleFromSchema(getResolvedRef(schema.anyOf[0]), options, level + 1))\n } else if (schema.oneOf?.[0] !== undefined) {\n Object.assign(response, getExampleFromSchema(getResolvedRef(schema.oneOf[0]), options, level + 1))\n } else if (schema.allOf?.[0]) {\n Object.assign(\n response,\n ...schema.allOf\n .filter(isDefined)\n .map((item) => getExampleFromSchema(getResolvedRef(item), options, level + 1, schema)),\n )\n }\n\n return cache(schema, response)\n }\n\n // Array\n if (schema.type === 'array' || schema.items !== undefined) {\n const items = getResolvedRef(schema.items)\n const itemsXmlTagName = items?.xml?.name\n const wrapItems = !!(options?.xml && schema.xml?.wrapped && itemsXmlTagName)\n\n if (schema.example !== undefined) {\n return cache(schema, wrapItems ? { [itemsXmlTagName]: schema.example } : schema.example)\n }\n\n // Check whether the array has a anyOf, oneOf, or allOf rule\n if (items) {\n // First handle allOf separately since it needs special handling\n if (items.allOf) {\n const allOf = items.allOf.filter(isDefined)\n const firstItem = getResolvedRef(allOf[0])\n\n // IfirstItemem is an object type, merge all schemas\n if (firstItem?.type === 'object') {\n const combined = { type: 'object', allOf } as SchemaObject\n\n const mergedExample = getExampleFromSchema(combined, options, level + 1, schema)\n\n return cache(schema, wrapItems ? [{ [itemsXmlTagName]: mergedExample }] : [mergedExample])\n }\n // For non-objects (like strings), collect all examples\n const examples = allOf\n .map((item) => getExampleFromSchema(getResolvedRef(item), options, level + 1, schema))\n .filter(isDefined)\n\n return cache(schema, wrapItems ? examples.map((example: any) => ({ [itemsXmlTagName]: example })) : examples)\n }\n\n // Handle other rules (anyOf, oneOf)\n const rules = ['anyOf', 'oneOf'] as const\n for (const rule of rules) {\n if (!items[rule]) {\n continue\n }\n\n const schemas = items[rule].slice(0, 1)\n const exampleFromRule = schemas\n .map((item) => getExampleFromSchema(getResolvedRef(item), options, level + 1, schema))\n .filter(isDefined)\n\n return cache(schema, wrapItems ? [{ [itemsXmlTagName]: exampleFromRule }] : exampleFromRule)\n }\n }\n\n // if it has type: 'object', or properties, it's an object\n const isObject = items?.type === 'object' || items?.properties !== undefined\n // if it has type: 'array', or items, it's an array\n const isArray = items?.type === 'array' || items?.items !== undefined\n\n if (items?.type || isObject || isArray) {\n const exampleFromSchema = getExampleFromSchema(items, options, level + 1)\n\n return wrapItems ? [{ [itemsXmlTagName]: exampleFromSchema }] : [exampleFromSchema]\n }\n\n return []\n }\n\n const exampleValues: Record<any, any> = {\n string: guessFromFormat(schema, makeUpRandomData, options?.emptyString),\n boolean: true,\n integer: schema.minimum ?? 1,\n number: schema.minimum ?? 1,\n array: [],\n }\n if (schema.type && !Array.isArray(schema.type) && exampleValues[schema.type] !== undefined) {\n return cache(schema, exampleValues[schema.type])\n }\n\n const discriminateSchema = schema.oneOf || schema.anyOf\n // Check if property has the `oneOf` | `anyOf` key\n if (Array.isArray(discriminateSchema) && discriminateSchema.length > 0) {\n // Find the first non-null type in the oneOf/anyOf array\n const firstNonNullItem = discriminateSchema.map((item) => getResolvedRef(item)).find((item) => item.type !== 'null')\n\n if (firstNonNullItem) {\n // Return an example for the first non-null item\n return getExampleFromSchema(firstNonNullItem, options, level + 1)\n }\n\n // If all items are null, return null\n return null\n }\n\n // Check if schema has the `allOf` key\n if (Array.isArray(schema.allOf)) {\n let example: any = null\n\n // Loop through all `allOf` schemas\n schema.allOf.forEach((allOfItem) => {\n // Return an example from the schema\n const newExample = getExampleFromSchema(getResolvedRef(allOfItem), options, level + 1)\n\n // Merge or overwrite the example\n example =\n typeof newExample === 'object' && typeof example === 'object'\n ? {\n ...(example ?? {}),\n ...newExample,\n }\n : Array.isArray(newExample) && Array.isArray(example)\n ? [...(example ?? {}), ...newExample]\n : newExample\n })\n\n return cache(schema, example)\n }\n\n // Check if schema is a union type\n if (Array.isArray(schema.type)) {\n // Return null if the type is nullable\n if (schema.type.includes('null')) {\n return null\n }\n // Return an example for the first type in the union\n const exampleValue = exampleValues[schema.type[0] ?? '']\n if (exampleValue !== undefined) {\n return cache(schema, exampleValue)\n }\n }\n\n // Warn if the type is unknown \u2026\n // console.warn(`[getExampleFromSchema] Unknown property type \"${schema.type}\".`)\n\n // \u2026 and just return null for now.\n return null\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB;
|
|
4
|
+
"sourcesContent": ["import { isDefined } from '@scalar/helpers/array/is-defined'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\n\nconst MAX_LEVELS_DEEP = 10\n/** Sets the max number of properties after the third level to prevent exponential horizontal growth */\nconst MAX_PROPERTIES = 10\n\n/** The default name for additional properties. */\nconst DEFAULT_ADDITIONAL_PROPERTIES_NAME = 'propertyName*'\n\n/** Pre-computed values to avoid expensive date operations */\nconst currentISOString = new Date().toISOString()\nconst currentDateString = currentISOString.split('T')[0]!\nconst currentTimeString = currentISOString.split('T')[1]!.split('.')[0]!\n\nconst genericExampleValues: Record<string, string> = {\n // 'date-time': '1970-01-01T00:00:00Z',\n 'date-time': currentISOString,\n // 'date': '1970-01-01',\n 'date': currentDateString,\n 'email': 'hello@example.com',\n 'hostname': 'example.com',\n // https://tools.ietf.org/html/rfc6531#section-3.3\n 'idn-email': 'jane.doe@example.com',\n // https://tools.ietf.org/html/rfc5890#section-2.3.2.3\n 'idn-hostname': 'example.com',\n 'ipv4': '127.0.0.1',\n 'ipv6': '51d4:7fab:bfbf:b7d7:b2cb:d4b4:3dad:d998',\n 'iri-reference': '/entitiy/1',\n // https://tools.ietf.org/html/rfc3987\n 'iri': 'https://example.com/entity/123',\n 'json-pointer': '/nested/objects',\n 'password': 'super-secret',\n 'regex': '/[a-z]/',\n // https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01\n 'relative-json-pointer': '1/nested/objects',\n // full-time in https://tools.ietf.org/html/rfc3339#section-5.6\n // 'time': '00:00:00Z',\n 'time': currentTimeString,\n // either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1\n 'uri-reference': '../folder',\n 'uri-template': 'https://example.com/{id}',\n 'uri': 'https://example.com',\n 'uuid': '123e4567-e89b-12d3-a456-426614174000',\n 'object-id': '6592008029c8c3e4dc76256c',\n}\n\n/**\n * We can use the `format` to generate some random values.\n */\nfunction guessFromFormat(schema: OpenAPIV3_1.SchemaObject, makeUpRandomData: boolean = false, fallback: string = '') {\n if (schema.format === 'binary') {\n return new File([''], 'filename')\n }\n return makeUpRandomData ? (genericExampleValues[schema.format ?? ''] ?? fallback) : ''\n}\n\n/** Map of all the results */\nconst resultCache = new WeakMap<Record<string, any>, any>()\n\n/** Store result in the cache, and return the result */\nfunction cache(schema: OpenAPIV3_1.SchemaObject, result: unknown) {\n // Avoid unnecessary WeakMap operations for primitive values\n if (typeof result !== 'object' || result === null) {\n return result\n }\n\n resultCache.set(schema, result)\n\n return result\n}\n\n/**\n * This function takes an OpenAPI schema and generates an example from it\n */\nexport const getExampleFromSchema = (\n _schema: OpenAPIV3_1.SchemaObject,\n options?: {\n /**\n * The fallback string for empty string values.\n * @default ''\n */\n emptyString?: string\n /**\n * Whether to use the XML tag names as keys\n * @default false\n */\n xml?: boolean\n /**\n * Whether to show read-only/write-only properties. Otherwise all properties are shown.\n * @default undefined\n */\n mode?: 'read' | 'write'\n /**\n * Dynamic values to add to the example.\n */\n variables?: Record<string, any>\n /**\n * Whether to omit empty and optional properties.\n * @default false\n */\n omitEmptyAndOptionalProperties?: boolean\n },\n level: number = 0,\n parentSchema?: OpenAPIV3_1.SchemaObject,\n name?: string,\n): any => {\n const schema = getResolvedRef(_schema)\n\n if (!isDefined(schema)) {\n return undefined\n }\n\n // Check if we have a cached result for this schema\n if (resultCache.has(schema)) {\n return resultCache.get(schema)\n }\n\n // Check depth limit\n if (level > MAX_LEVELS_DEEP) {\n return '[Max Depth Exceeded]'\n }\n\n // Sometimes, we just want the structure and no values.\n // But if `emptyString` is set, we do want to see some values.\n const makeUpRandomData = !!options?.emptyString\n\n // Early exits for simple cases\n // If the property is deprecated anyway, we don't want to show it.\n if (schema.deprecated) {\n return undefined\n }\n\n // Check if the property is read-only/write-only\n if ((options?.mode === 'write' && schema.readOnly) || (options?.mode === 'read' && schema.writeOnly)) {\n return undefined\n }\n\n // Use given variables as values\n if (schema['x-variable']) {\n const value = options?.variables?.[schema['x-variable']]\n\n // Return the value if it's defined\n if (value !== undefined) {\n // Type-casting\n if (schema.type === 'number' || schema.type === 'integer') {\n const numValue = Number.parseInt(value, 10)\n return cache(schema, numValue)\n }\n\n return cache(schema, value)\n }\n }\n\n // Use the first example, if there's an array\n if (Array.isArray(schema.examples) && schema.examples.length > 0) {\n return cache(schema, schema.examples[0])\n }\n\n // Use an example, if there's one\n if (schema.example !== undefined) {\n return cache(schema, schema.example)\n }\n\n // Use a default value, if there's one\n if (schema.default !== undefined) {\n return cache(schema, schema.default)\n }\n\n // Use a const value, if there's one\n if (schema.const !== undefined) {\n return cache(schema, schema.const)\n }\n\n // enum: [ 'available', 'pending', 'sold' ]\n if (Array.isArray(schema.enum) && schema.enum.length > 0) {\n return cache(schema, schema.enum[0])\n }\n\n // Check if the property is required\n const isObjectOrArray =\n schema.type === 'object' ||\n schema.type === 'array' ||\n !!schema.allOf?.at?.(0) ||\n !!schema.anyOf?.at?.(0) ||\n !!schema.oneOf?.at?.(0)\n if (!isObjectOrArray && options?.omitEmptyAndOptionalProperties === true) {\n const isRequired =\n schema.required === true ||\n parentSchema?.required === true ||\n parentSchema?.required?.includes(name ?? schema.title ?? '')\n\n if (!isRequired) {\n return undefined\n }\n }\n\n // Object\n if (schema.type === 'object' || schema.properties !== undefined) {\n const response: Record<string, any> = {}\n let propertyCount = 0\n\n // Regular properties - optimized iteration\n if (schema.properties !== undefined) {\n const propertyNames = Object.keys(schema.properties)\n const maxProps = level > 3 ? MAX_PROPERTIES : propertyNames.length\n\n for (const propertyName of propertyNames.slice(0, maxProps)) {\n const property = getResolvedRef(schema.properties[propertyName])\n\n if (!property) {\n continue\n }\n\n const propertyXmlTagName = options?.xml ? property?.xml?.name : undefined\n const value = getExampleFromSchema(property, options, level + 1, schema, propertyName)\n\n if (typeof value !== 'undefined') {\n response[propertyXmlTagName ?? propertyName] = value\n propertyCount++\n }\n }\n\n // Add truncation indicator if we hit the limit\n if (level > 3 && propertyCount >= MAX_PROPERTIES && propertyNames.length > MAX_PROPERTIES) {\n response['...'] = '[Additional Properties Truncated]'\n }\n }\n\n // Pattern properties (regex) - optimized iteration\n if (schema.patternProperties !== undefined) {\n for (const pattern of Object.keys(schema.patternProperties)) {\n const property = getResolvedRef(schema.patternProperties[pattern])\n if (!property) {\n continue\n }\n\n // Use the regex pattern as an example key\n response[pattern] = getExampleFromSchema(property, options, level + 1, schema, pattern)\n }\n }\n\n // Additional properties\n if (schema.additionalProperties !== undefined) {\n const anyTypeIsValid =\n // true\n schema.additionalProperties === true ||\n // or an empty object {}\n (typeof schema.additionalProperties === 'object' && !Object.keys(schema.additionalProperties).length)\n\n const additionalProperties = getResolvedRef(schema.additionalProperties)\n\n // Get the custom name for additional properties if available\n const additionalPropertiesName =\n typeof additionalProperties === 'object' &&\n additionalProperties['x-additionalPropertiesName'] &&\n typeof additionalProperties['x-additionalPropertiesName'] === 'string' &&\n additionalProperties['x-additionalPropertiesName'].trim().length > 0\n ? `${additionalProperties['x-additionalPropertiesName'].trim()}*`\n : DEFAULT_ADDITIONAL_PROPERTIES_NAME\n\n if (anyTypeIsValid) {\n response[additionalPropertiesName] = 'anything'\n } else if (typeof additionalProperties === 'object') {\n response[additionalPropertiesName] = getExampleFromSchema(additionalProperties, options, level + 1)\n }\n }\n\n if (schema.anyOf?.[0]) {\n Object.assign(response, getExampleFromSchema(getResolvedRef(schema.anyOf[0]), options, level + 1))\n } else if (schema.oneOf?.[0] !== undefined) {\n Object.assign(response, getExampleFromSchema(getResolvedRef(schema.oneOf[0]), options, level + 1))\n } else if (schema.allOf?.[0]) {\n Object.assign(\n response,\n ...schema.allOf\n .filter(isDefined)\n .map((item: any) => getExampleFromSchema(getResolvedRef(item), options, level + 1, schema)),\n )\n }\n\n // Check if we need to wrap the result in an XML root element name\n if (options?.xml && schema.xml?.name && level === 0) {\n const wrappedResponse: Record<string, any> = {}\n wrappedResponse[schema.xml.name] = response\n return cache(schema, wrappedResponse)\n }\n\n return cache(schema, response)\n }\n\n // Array\n if (schema.type === 'array' || schema.items !== undefined) {\n const items = getResolvedRef(schema.items)\n const itemsXmlTagName = items?.xml?.name\n const wrapItems = !!(options?.xml && schema.xml?.wrapped && itemsXmlTagName)\n\n if (schema.example !== undefined) {\n return cache(schema, wrapItems ? { [itemsXmlTagName]: schema.example } : schema.example)\n }\n\n // Check whether the array has a anyOf, oneOf, or allOf rule\n if (items) {\n // First handle allOf separately since it needs special handling\n if (items.allOf) {\n const allOf = items.allOf.filter(isDefined)\n const firstItem = getResolvedRef(allOf[0])\n\n // If first item is an object type, merge all schemas\n if (firstItem?.type === 'object') {\n const combined = { type: 'object', allOf } as OpenAPIV3_1.SchemaObject\n\n const mergedExample = getExampleFromSchema(combined, options, level + 1, schema)\n return cache(schema, wrapItems ? [{ [itemsXmlTagName]: mergedExample }] : [mergedExample])\n }\n // For non-objects (like strings), collect all examples\n const examples = allOf\n .map((item: any) => getExampleFromSchema(getResolvedRef(item), options, level + 1, schema))\n .filter(isDefined)\n\n return cache(schema, wrapItems ? examples.map((example: any) => ({ [itemsXmlTagName]: example })) : examples)\n }\n\n // Handle other rules (anyOf, oneOf) - optimized\n if (items.anyOf || items.oneOf) {\n const ruleItems = items.anyOf || items.oneOf\n if (ruleItems && ruleItems.length > 0) {\n const firstItem = ruleItems[0]\n if (firstItem) {\n const exampleFromRule = getExampleFromSchema(getResolvedRef(firstItem), options, level + 1, schema)\n\n return cache(schema, wrapItems ? [{ [itemsXmlTagName]: exampleFromRule }] : [exampleFromRule])\n }\n }\n }\n }\n\n // if it has type: 'object', or properties, it's an object\n const isObject = items?.type === 'object' || items?.properties !== undefined\n // if it has type: 'array', or items, it's an array\n const isArray = items?.type === 'array' || items?.items !== undefined\n\n if (items?.type || isObject || isArray) {\n const exampleFromSchema = getExampleFromSchema(items, options, level + 1)\n return cache(schema, wrapItems ? [{ [itemsXmlTagName]: exampleFromSchema }] : [exampleFromSchema])\n }\n\n return cache(schema, [])\n }\n\n const exampleValues: Record<any, any> = {\n string: guessFromFormat(schema, makeUpRandomData, options?.emptyString),\n boolean: true,\n integer: schema.minimum ?? 1,\n number: schema.minimum ?? 1,\n array: [],\n }\n if (schema.type && !Array.isArray(schema.type) && exampleValues[schema.type] !== undefined) {\n return cache(schema, exampleValues[schema.type])\n }\n\n const discriminateSchema = schema.oneOf || schema.anyOf\n // Check if property has the `oneOf` | `anyOf` key\n if (Array.isArray(discriminateSchema) && discriminateSchema.length > 0) {\n // Find the first non-null type in the oneOf/anyOf array\n const firstNonNullItem = discriminateSchema.map((item) => getResolvedRef(item)).find((item) => item.type !== 'null')\n\n if (firstNonNullItem) {\n // Return an example for the first non-null item\n const result = getExampleFromSchema(firstNonNullItem, options, level + 1)\n return cache(schema, result)\n }\n\n // If all items are null, return null\n return cache(schema, null)\n }\n\n // Check if schema has the `allOf` key\n if (Array.isArray(schema.allOf)) {\n let example: any = null\n\n // Loop through all `allOf` schemas\n schema.allOf.forEach((allOfItem) => {\n // Return an example from the schema\n const newExample = getExampleFromSchema(getResolvedRef(allOfItem), options, level + 1)\n\n // Merge or overwrite the example\n example =\n typeof newExample === 'object' && typeof example === 'object'\n ? {\n ...(example ?? {}),\n ...newExample,\n }\n : Array.isArray(newExample) && Array.isArray(example)\n ? [...(example ?? {}), ...newExample]\n : newExample\n })\n\n return cache(schema, example)\n }\n\n // Check if schema is a union type\n if (Array.isArray(schema.type)) {\n // Return null if the type is nullable\n if (schema.type.includes('null')) {\n return cache(schema, null)\n }\n // Return an example for the first type in the union\n const exampleValue = exampleValues[schema.type[0] ?? '']\n if (exampleValue !== undefined) {\n return cache(schema, exampleValue)\n }\n }\n\n // Warn if the type is unknown \u2026\n // console.warn(`[getExampleFromSchema] Unknown property type \"${schema.type}\".`)\n\n // \u2026 and just return null for now.\n return cache(schema, null)\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAE1B,SAAS,sBAAsB;AAE/B,MAAM,kBAAkB;AAExB,MAAM,iBAAiB;AAGvB,MAAM,qCAA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a,qBAAqB,eAAe,SAAS,GAAG,SAAS,QAAQ,CAAC;AAGrF,gBACE,OAAO,eAAe,YAAY,OAAO,YAAY,WACjD;AAAA,QACE,GAAI,WAAW,CAAC;AAAA,QAChB,GAAG;AAAA,MACL,IACA,MAAM,QAAQ,UAAU,KAAK,MAAM,QAAQ,OAAO,IAChD,CAAC,GAAI,WAAW,CAAC,GAAI,GAAG,UAAU,IAClC;AAAA,IACV,CAAC;AAED,WAAO,MAAM,QAAQ,OAAO;AAAA,EAC9B;AAGA,MAAI,MAAM,QAAQ,OAAO,IAAI,GAAG;AAE9B,QAAI,OAAO,KAAK,SAAS,MAAM,GAAG;AAChC,aAAO,MAAM,QAAQ,IAAI;AAAA,IAC3B;AAEA,UAAM,eAAe,cAAc,OAAO,KAAK,CAAC,KAAK,EAAE;AACvD,QAAI,iBAAiB,QAAW;AAC9B,aAAO,MAAM,QAAQ,YAAY;AAAA,IACnC;AAAA,EACF;AAMA,SAAO,MAAM,QAAQ,IAAI;AAC3B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-parameters-from-operation.d.ts","sourceRoot":"","sources":["../../src/spec-getters/get-parameters-from-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAGhD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,mBAAmB,EAAE,SAAS,CAAC,YAAY,CAAM,EACjD,cAAc,EAAE,WAAW,CAAC,eAAe,EAAE,YAAK,EAClD,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,EACnE,YAAY,GAAE,OAAc;;;;;;
|
|
1
|
+
{"version":3,"file":"get-parameters-from-operation.d.ts","sourceRoot":"","sources":["../../src/spec-getters/get-parameters-from-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAGhD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,mBAAmB,EAAE,SAAS,CAAC,YAAY,CAAM,EACjD,cAAc,EAAE,WAAW,CAAC,eAAe,EAAE,YAAK,EAClD,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,EACnE,YAAY,GAAE,OAAc;;;;;;IAkC7B"}
|
|
@@ -4,10 +4,7 @@ function getParametersFromOperation(operationParameters = [], pathParameters = [
|
|
|
4
4
|
const params = parameters.filter((parameter) => parameter.in === where).filter((parameter) => requiredOnly && parameter.required || !requiredOnly).map((parameter) => ({
|
|
5
5
|
name: parameter.name ?? "Unknown Parameter",
|
|
6
6
|
description: parameter.description ?? null,
|
|
7
|
-
value: parameter.example ? parameter.example : parameter.schema ? (
|
|
8
|
-
// @ts-expect-error not on the new store yet
|
|
9
|
-
getExampleFromSchema(parameter.schema, { mode: "write" })
|
|
10
|
-
) : "",
|
|
7
|
+
value: parameter.example ? parameter.example : parameter.schema ? getExampleFromSchema(parameter.schema, { mode: "write" }) : "",
|
|
11
8
|
required: parameter.required ?? false,
|
|
12
9
|
enabled: parameter.required ?? false
|
|
13
10
|
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/spec-getters/get-parameters-from-operation.ts"],
|
|
4
|
-
"sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nimport type { Operation } from '@/entities/spec'\nimport { getExampleFromSchema } from './get-example-from-schema'\n\n/**\n * Get the query parameters from an operation.\n *\n * Example: [ { name: 'foobar', value: '' } ]\n *\n * - OpenAPI 3.x: Possible values are \"query\", \"header\", \"path\" or \"cookie\".\n */\nexport function getParametersFromOperation(\n operationParameters: Operation['parameters'] = [],\n pathParameters: OpenAPIV3_1.ParameterObject[] = [],\n where: 'query' | 'header' | 'path' | 'cookie' | 'formData' | 'body',\n requiredOnly: boolean = true,\n) {\n const parameters = [...(pathParameters || []), ...(operationParameters || [])]\n\n const params = parameters\n // query, path, header, cookie?\n .filter((parameter) => parameter.in === where)\n // don't add optional parameters\n .filter((parameter) => (requiredOnly && parameter.required) || !requiredOnly)\n // transform them\n .map((parameter) => ({\n name: parameter.name ?? 'Unknown Parameter',\n description: parameter.description ?? null,\n value: parameter.example\n ? parameter.example\n : parameter.schema\n ?
|
|
5
|
-
"mappings": "AAGA,SAAS,4BAA4B;AAS9B,SAAS,2BACd,sBAA+C,CAAC,GAChD,iBAAgD,CAAC,GACjD,OACA,eAAwB,MACxB;AACA,QAAM,aAAa,CAAC,GAAI,kBAAkB,CAAC,GAAI,GAAI,uBAAuB,CAAC,CAAE;AAE7E,QAAM,SAAS,WAEZ,OAAO,CAAC,cAAc,UAAU,OAAO,KAAK,EAE5C,OAAO,CAAC,cAAe,gBAAgB,UAAU,YAAa,CAAC,YAAY,EAE3E,IAAI,CAAC,eAAe;AAAA,IACnB,MAAM,UAAU,QAAQ;AAAA,IACxB,aAAa,UAAU,eAAe;AAAA,IACtC,OAAO,UAAU,UACb,UAAU,UACV,UAAU
|
|
4
|
+
"sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nimport type { Operation } from '@/entities/spec'\nimport { getExampleFromSchema } from './get-example-from-schema'\n\n/**\n * Get the query parameters from an operation.\n *\n * Example: [ { name: 'foobar', value: '' } ]\n *\n * - OpenAPI 3.x: Possible values are \"query\", \"header\", \"path\" or \"cookie\".\n */\nexport function getParametersFromOperation(\n operationParameters: Operation['parameters'] = [],\n pathParameters: OpenAPIV3_1.ParameterObject[] = [],\n where: 'query' | 'header' | 'path' | 'cookie' | 'formData' | 'body',\n requiredOnly: boolean = true,\n) {\n const parameters = [...(pathParameters || []), ...(operationParameters || [])]\n\n const params = parameters\n // query, path, header, cookie?\n .filter((parameter) => parameter.in === where)\n // don't add optional parameters\n .filter((parameter) => (requiredOnly && parameter.required) || !requiredOnly)\n // transform them\n .map((parameter) => ({\n name: parameter.name ?? 'Unknown Parameter',\n description: parameter.description ?? null,\n value: parameter.example\n ? parameter.example\n : parameter.schema\n ? getExampleFromSchema(parameter.schema, { mode: 'write' })\n : '',\n required: parameter.required ?? false,\n enabled: parameter.required ?? false,\n }))\n\n return params.sort((a, b) => {\n // Move a up if a is required and b is not\n if (a.required && !b.required) {\n return -1\n }\n // Move b up if b is required and a is not\n if (!a.required && b.required) {\n return 1\n }\n // Keep original order if both have the same required status\n return 0\n })\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,4BAA4B;AAS9B,SAAS,2BACd,sBAA+C,CAAC,GAChD,iBAAgD,CAAC,GACjD,OACA,eAAwB,MACxB;AACA,QAAM,aAAa,CAAC,GAAI,kBAAkB,CAAC,GAAI,GAAI,uBAAuB,CAAC,CAAE;AAE7E,QAAM,SAAS,WAEZ,OAAO,CAAC,cAAc,UAAU,OAAO,KAAK,EAE5C,OAAO,CAAC,cAAe,gBAAgB,UAAU,YAAa,CAAC,YAAY,EAE3E,IAAI,CAAC,eAAe;AAAA,IACnB,MAAM,UAAU,QAAQ;AAAA,IACxB,aAAa,UAAU,eAAe;AAAA,IACtC,OAAO,UAAU,UACb,UAAU,UACV,UAAU,SACR,qBAAqB,UAAU,QAAQ,EAAE,MAAM,QAAQ,CAAC,IACxD;AAAA,IACN,UAAU,UAAU,YAAY;AAAA,IAChC,SAAS,UAAU,YAAY;AAAA,EACjC,EAAE;AAEJ,SAAO,OAAO,KAAK,CAAC,GAAG,MAAM;AAE3B,QAAI,EAAE,YAAY,CAAC,EAAE,UAAU;AAC7B,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,EAAE,YAAY,EAAE,UAAU;AAC7B,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -97,7 +97,7 @@ function getRequestBodyFromOperation(operation, selectedExampleKey, omitEmptyAnd
|
|
|
97
97
|
}) : null;
|
|
98
98
|
return {
|
|
99
99
|
mimeType,
|
|
100
|
-
text: example ?? json2xml(exampleFromSchema
|
|
100
|
+
text: example ?? json2xml(exampleFromSchema)
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
if (mimeType === "application/octet-stream") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/spec-getters/get-request-body-from-operation.ts"],
|
|
4
|
-
"sourcesContent": ["import { json2xml } from '@scalar/helpers/file/json2xml'\nimport type { ContentType } from '@scalar/types/legacy'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\n\nimport type { Operation } from '@/entities/spec'\nimport { normalizeMimeTypeObject } from '@/helpers/normalize-mime-type-object'\nimport { prettyPrintJson } from '@/helpers/pretty-print-json'\nimport { getExampleFromSchema } from './get-example-from-schema'\nimport { getParametersFromOperation } from './get-parameters-from-operation'\n\ntype AnyObject = Record<string, any>\n\n/**\n * Transform the object into a nested array of objects\n * that represent the key-value pairs of the object.\n */\nfunction getParamsFromObject(\n obj: AnyObject,\n nested = false,\n field?: string,\n): {\n name: string\n value: any\n}[] {\n return Object.entries(obj).flatMap(([key, value]) => {\n const name = field ?? key\n\n if (Array.isArray(value) && !nested) {\n return getParamsFromObject(value, true, key)\n }\n\n if (typeof value === 'object' && !(value instanceof File) && value !== null) {\n // Nested object inside formData field: no way to represent it, so just serialize to JSON string\n value = JSON.stringify(value)\n }\n\n return [{ name, value }]\n })\n}\n// Define preferred standard mime types (order indicates preference)\nconst standardMimeTypes: ContentType[] = [\n 'application/json',\n 'application/octet-stream',\n 'application/x-www-form-urlencoded',\n 'application/xml',\n 'multipart/form-data',\n 'text/plain',\n]\n\n/**\n * Get the request body from the operation.\n */\nexport function getRequestBodyFromOperation(\n operation: Pick<Operation, 'requestBody' | 'parameters'>,\n selectedExampleKey?: string | number,\n omitEmptyAndOptionalProperties?: boolean,\n): {\n mimeType: ContentType\n text?: string | undefined\n params?: {\n name: string\n value?: string | File\n }[]\n} | null {\n const originalContent = operation.requestBody?.content\n const content = normalizeMimeTypeObject(originalContent)\n\n // First try to find a standard mime type\n const mimeType =\n standardMimeTypes.find((currentMimeType) => !!content?.[currentMimeType]) ??\n ((Object.keys(content ?? {})[0] || 'application/json') as ContentType)\n\n // Handle JSON-like content types (e.g., application/vnd.github+json)\n const isJsonLike = mimeType.includes('json') || mimeType.endsWith('+json')\n\n /** Examples */\n const examples = content?.[mimeType]?.examples ?? content?.['application/json']?.examples\n\n // Let's use the first example\n const selectedExample = examples?.[selectedExampleKey ?? Object.keys(examples ?? {})[0] ?? '']\n\n if (selectedExample) {\n return {\n mimeType,\n text: prettyPrintJson('value' in selectedExample ? selectedExample.value : selectedExample),\n }\n }\n\n /**\n * Body Parameters (Swagger 2.0)\n *\n * \u201DThe payload that's appended to the HTTP request. Since there can only be one payload, there can only\n * be one body parameter. The name of the body parameter has no effect on the parameter itself and is used\n * for documentation purposes only. Since Form parameters are also in the payload, body and form\n * parameters cannot exist together for the same operation.\u201D\n */\n const bodyParameters = getParametersFromOperation(\n operation.parameters ?? [],\n // TODO: Add path parameters\n [], // operation.path ?? [],\n 'body',\n false,\n )\n\n if (bodyParameters.length > 0) {\n return {\n mimeType: 'application/json',\n text: prettyPrintJson(bodyParameters[0]?.value ?? ''),\n }\n }\n\n /**\n * FormData Parameters (Swagger 2.0)\n *\n * \u201DForm - Used to describe the payload of an HTTP request when either application/x-www-form-urlencoded,\n * multipart/form-data or both are used as the content type of the request (in Swagger's definition, the\n * consumes property of an operation). This is the only parameter type that can be used to send files,\n * thus supporting the file type. Since form parameters are sent in the payload, they cannot be declared\n * together with a body parameter for the same operation. Form parameters have a different format based on\n * the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4):\n * - application/x-www-form-urlencoded - Similar to the format of Query parameters but as a payload.\n * For example, foo=1&bar=swagger - both foo and bar are form parameters. This is normally used for simple\n * parameters that are being transferred.\n * - multipart/form-data - each parameter takes a section in the payload with an internal header.\n * For example, for the header Content-Disposition: form-data; name=\"submit-name\" the name of the parameter is\n * submit-name. This type of form parameters is more commonly used for file transfers.\u201D\n */\n\n const formDataParameters = getParametersFromOperation(\n operation.parameters ?? [],\n // TODO: Add path parameters\n [], // operation.path ?? [],\n 'formData',\n false,\n )\n\n if (formDataParameters.length > 0) {\n return {\n mimeType: 'application/x-www-form-urlencoded',\n params: formDataParameters.map((parameter) => ({\n name: parameter.name,\n /**\n * TODO: This value MUST be a string\n * Figure out why this is not always a string\n *\n * JSON.stringify is a TEMPORARY fix\n */\n value: typeof parameter.value === 'string' ? parameter.value : JSON.stringify(parameter.value),\n })),\n }\n }\n\n // If no mime type is supported, exit early\n if (!mimeType) {\n return null\n }\n\n // Get the request body object for the mime type\n const requestBodyObject = content?.[mimeType]\n\n // Get example from operation\n const example = requestBodyObject?.example ? requestBodyObject?.example : undefined\n\n // Update the JSON handling section\n if (isJsonLike) {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(getResolvedRef(requestBodyObject?.schema), {\n mode: 'write',\n omitEmptyAndOptionalProperties: omitEmptyAndOptionalProperties ?? false,\n })\n : null\n\n const body = example ?? exampleFromSchema\n\n return {\n mimeType,\n text: body ? (typeof body === 'string' ? body : JSON.stringify(body, null, 2)) : undefined,\n }\n }\n\n // XML\n if (mimeType === 'application/xml') {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(getResolvedRef(requestBodyObject?.schema), {\n xml: true,\n mode: 'write',\n })\n : null\n\n return {\n mimeType,\n text: example ?? json2xml(exampleFromSchema
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB;AAEzB,SAAS,sBAAsB;AAG/B,SAAS,+BAA+B;AACxC,SAAS,uBAAuB;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xml } from '@scalar/helpers/file/json2xml'\nimport type { ContentType } from '@scalar/types/legacy'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\n\nimport type { Operation } from '@/entities/spec'\nimport { normalizeMimeTypeObject } from '@/helpers/normalize-mime-type-object'\nimport { prettyPrintJson } from '@/helpers/pretty-print-json'\nimport { getExampleFromSchema } from './get-example-from-schema'\nimport { getParametersFromOperation } from './get-parameters-from-operation'\n\ntype AnyObject = Record<string, any>\n\n/**\n * Transform the object into a nested array of objects\n * that represent the key-value pairs of the object.\n */\nfunction getParamsFromObject(\n obj: AnyObject,\n nested = false,\n field?: string,\n): {\n name: string\n value: any\n}[] {\n return Object.entries(obj).flatMap(([key, value]) => {\n const name = field ?? key\n\n if (Array.isArray(value) && !nested) {\n return getParamsFromObject(value, true, key)\n }\n\n if (typeof value === 'object' && !(value instanceof File) && value !== null) {\n // Nested object inside formData field: no way to represent it, so just serialize to JSON string\n value = JSON.stringify(value)\n }\n\n return [{ name, value }]\n })\n}\n// Define preferred standard mime types (order indicates preference)\nconst standardMimeTypes: ContentType[] = [\n 'application/json',\n 'application/octet-stream',\n 'application/x-www-form-urlencoded',\n 'application/xml',\n 'multipart/form-data',\n 'text/plain',\n]\n\n/**\n * Get the request body from the operation.\n */\nexport function getRequestBodyFromOperation(\n operation: Pick<Operation, 'requestBody' | 'parameters'>,\n selectedExampleKey?: string | number,\n omitEmptyAndOptionalProperties?: boolean,\n): {\n mimeType: ContentType\n text?: string | undefined\n params?: {\n name: string\n value?: string | File\n }[]\n} | null {\n const originalContent = operation.requestBody?.content\n const content = normalizeMimeTypeObject(originalContent)\n\n // First try to find a standard mime type\n const mimeType =\n standardMimeTypes.find((currentMimeType) => !!content?.[currentMimeType]) ??\n ((Object.keys(content ?? {})[0] || 'application/json') as ContentType)\n\n // Handle JSON-like content types (e.g., application/vnd.github+json)\n const isJsonLike = mimeType.includes('json') || mimeType.endsWith('+json')\n\n /** Examples */\n const examples = content?.[mimeType]?.examples ?? content?.['application/json']?.examples\n\n // Let's use the first example\n const selectedExample = examples?.[selectedExampleKey ?? Object.keys(examples ?? {})[0] ?? '']\n\n if (selectedExample) {\n return {\n mimeType,\n text: prettyPrintJson('value' in selectedExample ? selectedExample.value : selectedExample),\n }\n }\n\n /**\n * Body Parameters (Swagger 2.0)\n *\n * \u201DThe payload that's appended to the HTTP request. Since there can only be one payload, there can only\n * be one body parameter. The name of the body parameter has no effect on the parameter itself and is used\n * for documentation purposes only. Since Form parameters are also in the payload, body and form\n * parameters cannot exist together for the same operation.\u201D\n */\n const bodyParameters = getParametersFromOperation(\n operation.parameters ?? [],\n // TODO: Add path parameters\n [], // operation.path ?? [],\n 'body',\n false,\n )\n\n if (bodyParameters.length > 0) {\n return {\n mimeType: 'application/json',\n text: prettyPrintJson(bodyParameters[0]?.value ?? ''),\n }\n }\n\n /**\n * FormData Parameters (Swagger 2.0)\n *\n * \u201DForm - Used to describe the payload of an HTTP request when either application/x-www-form-urlencoded,\n * multipart/form-data or both are used as the content type of the request (in Swagger's definition, the\n * consumes property of an operation). This is the only parameter type that can be used to send files,\n * thus supporting the file type. Since form parameters are sent in the payload, they cannot be declared\n * together with a body parameter for the same operation. Form parameters have a different format based on\n * the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4):\n * - application/x-www-form-urlencoded - Similar to the format of Query parameters but as a payload.\n * For example, foo=1&bar=swagger - both foo and bar are form parameters. This is normally used for simple\n * parameters that are being transferred.\n * - multipart/form-data - each parameter takes a section in the payload with an internal header.\n * For example, for the header Content-Disposition: form-data; name=\"submit-name\" the name of the parameter is\n * submit-name. This type of form parameters is more commonly used for file transfers.\u201D\n */\n\n const formDataParameters = getParametersFromOperation(\n operation.parameters ?? [],\n // TODO: Add path parameters\n [], // operation.path ?? [],\n 'formData',\n false,\n )\n\n if (formDataParameters.length > 0) {\n return {\n mimeType: 'application/x-www-form-urlencoded',\n params: formDataParameters.map((parameter) => ({\n name: parameter.name,\n /**\n * TODO: This value MUST be a string\n * Figure out why this is not always a string\n *\n * JSON.stringify is a TEMPORARY fix\n */\n value: typeof parameter.value === 'string' ? parameter.value : JSON.stringify(parameter.value),\n })),\n }\n }\n\n // If no mime type is supported, exit early\n if (!mimeType) {\n return null\n }\n\n // Get the request body object for the mime type\n const requestBodyObject = content?.[mimeType]\n\n // Get example from operation\n const example = requestBodyObject?.example ? requestBodyObject?.example : undefined\n\n // Update the JSON handling section\n if (isJsonLike) {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(getResolvedRef(requestBodyObject?.schema), {\n mode: 'write',\n omitEmptyAndOptionalProperties: omitEmptyAndOptionalProperties ?? false,\n })\n : null\n\n const body = example ?? exampleFromSchema\n\n return {\n mimeType,\n text: body ? (typeof body === 'string' ? body : JSON.stringify(body, null, 2)) : undefined,\n }\n }\n\n // XML\n if (mimeType === 'application/xml') {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(getResolvedRef(requestBodyObject?.schema), {\n xml: true,\n mode: 'write',\n })\n : null\n\n return {\n mimeType,\n text: example ?? json2xml(exampleFromSchema),\n }\n }\n\n // Binary data\n if (mimeType === 'application/octet-stream') {\n return {\n mimeType,\n text: 'BINARY',\n }\n }\n\n // Plain text\n if (mimeType === 'text/plain') {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(getResolvedRef(requestBodyObject?.schema), {\n xml: true,\n mode: 'write',\n })\n : null\n\n return {\n mimeType,\n text: example ?? exampleFromSchema ?? '',\n }\n }\n\n // URL encoded data\n if (mimeType === 'multipart/form-data' || mimeType === 'application/x-www-form-urlencoded') {\n const exampleFromSchema = requestBodyObject?.schema\n ? getExampleFromSchema(getResolvedRef(requestBodyObject?.schema), {\n xml: true,\n mode: 'write',\n })\n : null\n\n return {\n mimeType,\n params: getParamsFromObject(example ?? exampleFromSchema ?? {}),\n }\n }\n\n return null\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AAEzB,SAAS,sB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MAAM,WAAW,SAAS,iBAAiB;AAAA,IAC7C;AAAA,EACF;AAGA,MAAI,aAAa,4BAA4B;AAC3C,WAAO;AAAA,MACL;AAAA,MACA,MAAM;AAAA,IACR;AAAA,EACF;AAGA,MAAI,aAAa,cAAc;AAC7B,UAAM,oBAAoB,mBAAmB,SACzC,qBAAqB,eAAe,mBAAmB,MAAM,GAAG;AAAA,MAC9D,KAAK;AAAA,MACL,MAAM;AAAA,IACR,CAAC,IACD;AAEJ,WAAO;AAAA,MACL;AAAA,MACA,MAAM,WAAW,qBAAqB;AAAA,IACxC;AAAA,EACF;AAGA,MAAI,aAAa,yBAAyB,aAAa,qCAAqC;AAC1F,UAAM,oBAAoB,mBAAmB,SACzC,qBAAqB,eAAe,mBAAmB,MAAM,GAAG;AAAA,MAC9D,KAAK;AAAA,MACL,MAAM;AAAA,IACR,CAAC,IACD;AAEJ,WAAO;AAAA,MACL;AAAA,MACA,QAAQ,oBAAoB,WAAW,qBAAqB,CAAC,CAAC;AAAA,IAChE;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-server-variable-examples.d.ts","sourceRoot":"","sources":["../../src/spec-getters/get-server-variable-examples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD,mDAAmD;AACnD,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"get-server-variable-examples.d.ts","sourceRoot":"","sources":["../../src/spec-getters/get-server-variable-examples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD,mDAAmD;AACnD,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,6BAUvD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import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