@scalar/oas-utils 0.4.8 → 0.4.11

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 (44) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/entities/spec/operation.d.ts +16 -16
  3. package/dist/entities/spec/parameters.d.ts +2 -2
  4. package/dist/entities/spec/request-examples.d.ts +77 -77
  5. package/dist/entities/spec/request-examples.d.ts.map +1 -1
  6. package/dist/entities/spec/request-examples.js +1 -6
  7. package/dist/entities/spec/request-examples.js.map +2 -2
  8. package/dist/entities/spec/requests.d.ts +28 -28
  9. package/dist/entities/spec/server.js.map +1 -1
  10. package/dist/helpers/fetch-document.js.map +1 -1
  11. package/dist/helpers/operation-to-har/operation-to-har.d.ts +13 -10
  12. package/dist/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
  13. package/dist/helpers/operation-to-har/operation-to-har.js +10 -2
  14. package/dist/helpers/operation-to-har/operation-to-har.js.map +2 -2
  15. package/dist/helpers/operation-to-har/process-body.d.ts +1 -1
  16. package/dist/helpers/operation-to-har/process-body.d.ts.map +1 -1
  17. package/dist/helpers/operation-to-har/process-body.js +82 -3
  18. package/dist/helpers/operation-to-har/process-body.js.map +2 -2
  19. package/dist/helpers/operation-to-har/process-parameters.d.ts +8 -2
  20. package/dist/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
  21. package/dist/helpers/operation-to-har/process-parameters.js +89 -5
  22. package/dist/helpers/operation-to-har/process-parameters.js.map +3 -3
  23. package/dist/helpers/operation-to-har/process-security-schemes.d.ts +4 -2
  24. package/dist/helpers/operation-to-har/process-security-schemes.d.ts.map +1 -1
  25. package/dist/helpers/operation-to-har/process-security-schemes.js +10 -17
  26. package/dist/helpers/operation-to-har/process-security-schemes.js.map +2 -2
  27. package/dist/helpers/operation-to-har/process-server-url.d.ts +2 -2
  28. package/dist/helpers/operation-to-har/process-server-url.d.ts.map +1 -1
  29. package/dist/helpers/operation-to-har/process-server-url.js.map +2 -2
  30. package/dist/helpers/redirect-to-proxy.d.ts +1 -1
  31. package/dist/helpers/redirect-to-proxy.js.map +1 -1
  32. package/dist/spec-getters/get-example-from-schema.js.map +1 -1
  33. package/dist/spec-getters/get-parameters-from-operation.d.ts +9 -4
  34. package/dist/spec-getters/get-parameters-from-operation.d.ts.map +1 -1
  35. package/dist/spec-getters/get-parameters-from-operation.js.map +2 -2
  36. package/dist/spec-getters/get-request-body-from-operation.d.ts +3 -2
  37. package/dist/spec-getters/get-request-body-from-operation.d.ts.map +1 -1
  38. package/dist/spec-getters/get-request-body-from-operation.js +9 -5
  39. package/dist/spec-getters/get-request-body-from-operation.js.map +2 -2
  40. package/dist/transforms/import-spec.d.ts +1 -1
  41. package/dist/transforms/import-spec.d.ts.map +1 -1
  42. package/dist/transforms/import-spec.js +22 -3
  43. package/dist/transforms/import-spec.js.map +2 -2
  44. package/package.json +15 -14
@@ -1 +1 @@
1
- {"version":3,"file":"request-examples.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/request-examples.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,cAAc,CAAA;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAOtC;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuCvC,CAAA;AAEJ,+EAA+E;AAC/E,eAAO,MAAM,sBAAsB,WAAY,uBAAuB,EAAE,2BAIhE,CAAA;AAER,kFAAkF;AAClF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AAEpF,eAAO,MAAM,sBAAsB;;;;;;;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;;;;;;;;;;;EAsH1D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CAoHxG"}
@@ -267,12 +267,7 @@ function createExampleFromRequest(request, name, server) {
267
267
  activeBody: "raw"
268
268
  };
269
269
  if (request.requestBody || contentTypeHeader?.value) {
270
- const requestBody = getRequestBodyFromOperation({
271
- information: {
272
- parameters: request.parameters ?? [],
273
- requestBody: request.requestBody
274
- }
275
- });
270
+ const requestBody = getRequestBodyFromOperation(request);
276
271
  const contentType = request.requestBody ? requestBody?.mimeType : contentTypeHeader?.value;
277
272
  if (contentType?.includes("/json") || contentType?.endsWith("+json")) {
278
273
  body.activeBody = "raw";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/entities/spec/request-examples.ts"],
4
- "sourcesContent": ["import { schemaModel } from '@/helpers/schema-model'\nimport { getServerVariableExamples } from '@/spec-getters/get-server-variable-examples'\nimport { keysOf } from '@scalar/object-utils/arrays'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nimport { getRequestBodyFromOperation } from '@/spec-getters/get-request-body-from-operation'\nimport type { RequestParameter, ParameterContent } from './parameters'\nimport type { Request } from './requests'\nimport type { Server } from './server'\nimport { isDefined } from '@scalar/helpers/array/is-defined'\nimport { objectKeys } from '@scalar/helpers/object/object-keys'\n\n// ---------------------------------------------------------------------------\n// Example Parameters\n\n/**\n * TODO: Deprecate this.\n *\n * The request schema should be stored in the request and any\n * parameters should be validated against that\n */\nexport const requestExampleParametersSchema = z\n .object({\n key: z.string().default(''),\n value: z.coerce.string().default(''),\n enabled: z.boolean().default(true),\n file: z.any().optional(),\n description: z.string().optional(),\n required: z.boolean().optional(),\n enum: z.array(z.string()).optional(),\n examples: z.array(z.any()).optional(),\n type: z\n .union([\n // 'string'\n z.string(),\n // ['string', 'null']\n z.array(z.string()),\n ])\n .optional(),\n format: z.string().optional(),\n minimum: z.number().optional(),\n maximum: z.number().optional(),\n default: z.any().optional(),\n nullable: z.boolean().optional(),\n })\n // set nullable: to true if type is ['string', 'null']\n .transform((_data) => {\n const data = { ..._data }\n\n // type: ['string', 'null'] -> nullable: true\n if (Array.isArray(data.type) && data.type.includes('null')) {\n data.nullable = true\n }\n\n // Hey, if it's just one value and 'null', we can make it a string and ditch the 'null'.\n if (Array.isArray(data.type) && data.type.length === 2 && data.type.includes('null')) {\n data.type = data.type.find((item) => item !== 'null')\n }\n\n return data\n })\n\n/** Convert the array of parameters to an object keyed by the parameter name */\nexport const parameterArrayToObject = (params: RequestExampleParameter[]) =>\n params.reduce<Record<string, string>>((map, param) => {\n map[param.key] = param.value\n return map\n }, {})\n\n/** Request examples - formerly known as instances - are \"children\" of requests */\nexport type RequestExampleParameter = z.infer<typeof requestExampleParametersSchema>\n\nexport const xScalarFileValueSchema = z\n .object({\n url: z.string(),\n base64: z.string().optional(),\n })\n .nullable()\n\n/**\n * When files are required for an example we provide the options\n * to provide a public URL or a base64 encoded string\n */\nexport type XScalarFileValue = z.infer<typeof xScalarFileValueSchema>\n\n/**\n * Schema for the OAS serialization of request example parameters\n *\n * File values can be optionally fetched on import OR inserted as a base64 encoded string\n */\nexport const xScalarFormDataValue = z.union([\n z.object({\n type: z.literal('string'),\n value: z.string(),\n }),\n z.object({\n type: z.literal('file'),\n file: xScalarFileValueSchema,\n }),\n])\n\nexport type XScalarFormDataValue = z.infer<typeof xScalarFormDataValue>\n\n// ---------------------------------------------------------------------------\n// Example Body\n\n/**\n * Possible encodings for example request bodies when using text formats\n *\n * TODO: This list may not be comprehensive enough\n */\nexport const exampleRequestBodyEncoding = ['json', 'text', 'html', 'javascript', 'xml', 'yaml', 'edn'] as const\n\nexport type BodyEncoding = (typeof exampleRequestBodyEncoding)[number]\n\nexport const exampleBodyMime = [\n 'application/json',\n 'text/plain',\n 'text/html',\n 'application/javascript',\n 'application/xml',\n 'application/yaml',\n 'application/edn',\n 'application/octet-stream',\n 'application/x-www-form-urlencoded',\n 'multipart/form-data',\n /** Used for direct files */\n 'binary',\n] as const\n\nexport type BodyMime = (typeof exampleBodyMime)[number]\n\nconst contentMapping: Record<BodyEncoding, BodyMime> = {\n json: 'application/json',\n text: 'text/plain',\n html: 'text/html',\n javascript: 'application/javascript',\n xml: 'application/xml',\n yaml: 'application/yaml',\n edn: 'application/edn',\n} as const\n\n/**\n * TODO: Migrate away from this layout to the format used in the extension\n *\n * If a user changes the encoding of the body we expect the content to change as well\n */\nexport const exampleRequestBodySchema = z.object({\n raw: z\n .object({\n encoding: z.enum(exampleRequestBodyEncoding),\n value: z.string().default(''),\n mimeType: z.string().optional(),\n })\n .optional(),\n formData: z\n .object({\n encoding: z.union([z.literal('form-data'), z.literal('urlencoded')]).default('form-data'),\n value: requestExampleParametersSchema.array().default([]),\n })\n .optional(),\n binary: z.instanceof(Blob).optional(),\n activeBody: z.union([z.literal('raw'), z.literal('formData'), z.literal('binary')]).default('raw'),\n})\n\nexport type ExampleRequestBody = z.infer<typeof exampleRequestBodySchema>\n\n/** Schema for the OAS serialization of request example bodies */\nexport const xScalarExampleBodySchema = z.object({\n encoding: z.enum(exampleBodyMime),\n /**\n * Body content as an object with a separately specified encoding or a simple pre-encoded string value\n *\n * Ideally we would convert any objects into the proper encoding on import\n */\n content: z.union([z.record(z.string(), z.any()), z.string()]),\n /** When the encoding is `binary` this will be used to link to the file */\n file: xScalarFileValueSchema.optional(),\n})\n\nexport type XScalarExampleBody = z.infer<typeof xScalarExampleBodySchema>\n\n// ---------------------------------------------------------------------------\n// Example Schema\n\nexport const requestExampleSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['EXAMPLE']>(),\n type: z.literal('requestExample').optional().default('requestExample'),\n requestUid: z.string().brand<ENTITY_BRANDS['OPERATION']>().optional(),\n name: z.string().optional().default('Name'),\n body: exampleRequestBodySchema.optional().default({}),\n parameters: z\n .object({\n path: requestExampleParametersSchema.array().default([]),\n query: requestExampleParametersSchema.array().default([]),\n headers: requestExampleParametersSchema.array().default([{ key: 'Accept', value: '*/*', enabled: true }]),\n cookies: requestExampleParametersSchema.array().default([]),\n })\n .optional()\n .default({}),\n /** TODO: Should this be deprecated? */\n serverVariables: z.record(z.string(), z.array(z.string())).optional(),\n})\n\nexport type RequestExample = z.infer<typeof requestExampleSchema>\n\n/** For OAS serialization we just store the simple key/value pairs */\nconst xScalarExampleParameterSchema = z.record(z.string(), z.string()).optional()\n\n/** Schema for the OAS serialization of request examples */\nexport const xScalarExampleSchema = z.object({\n /** TODO: Should this be required? */\n name: z.string().optional(),\n body: xScalarExampleBodySchema.optional(),\n parameters: z.object({\n path: xScalarExampleParameterSchema,\n query: xScalarExampleParameterSchema,\n headers: xScalarExampleParameterSchema,\n cookies: xScalarExampleParameterSchema,\n }),\n})\n\nexport type XScalarExample = z.infer<typeof xScalarExampleSchema>\n\n/**\n * Convert a request example to the xScalar serialized format\n *\n * TODO: The base format should be migrated to align MUCH closer to the serialized format\n */\nexport function convertExampleToXScalar(example: RequestExample) {\n const active = example.body?.activeBody\n\n const xScalarBody: XScalarExampleBody = {\n encoding: 'text/plain',\n content: '',\n }\n\n if (example.body?.activeBody === 'binary') {\n xScalarBody.encoding = 'binary'\n // TODO: Need to allow users to set these properties\n xScalarBody.file = null\n }\n\n if (active === 'formData' && example.body?.[active]) {\n const body = example.body[active]\n xScalarBody.encoding = body.encoding === 'form-data' ? 'multipart/form-data' : 'application/x-www-form-urlencoded'\n\n // TODO: Need to allow users to set these properties\n xScalarBody.content = body.value.reduce<Record<string, XScalarFormDataValue>>((map, param) => {\n /** TODO: We need to ensure only file or value is set */\n map[param.key] = param.file\n ? {\n type: 'file',\n file: null,\n }\n : {\n type: 'string',\n value: param.value,\n }\n return map\n }, {})\n }\n\n if (example.body?.activeBody === 'raw') {\n xScalarBody.encoding = contentMapping[example.body.raw?.encoding ?? 'text'] ?? 'text/plain'\n\n xScalarBody.content = example.body.raw?.value ?? ''\n }\n\n const parameters: XScalarExample['parameters'] = {}\n\n keysOf(example.parameters ?? {}).forEach((key) => {\n if (example.parameters?.[key].length) {\n parameters[key] = parameterArrayToObject(example.parameters[key])\n }\n })\n\n return xScalarExampleSchema.parse({\n /** Only add the body if we have content or the body should be a file */\n body: xScalarBody.content || xScalarBody.encoding === 'binary' ? xScalarBody : undefined,\n parameters,\n })\n}\n\n// ---------------------------------------------------------------------------\n// Example Helpers\n\n/** Create new instance parameter from a request parameter */\nexport function createParamInstance(param: RequestParameter) {\n const schema = param.schema as any\n\n const firstExample = (() => {\n if (param.examples && !Array.isArray(param.examples) && objectKeys(param.examples).length > 0) {\n const exampleValues = Object.entries(param.examples).map(([_, example]) => {\n // returns the external value if it exists\n if (example.externalValue) {\n return example.externalValue\n }\n\n // returns the value if it exists and is defined\n // e.g. { examples: { foo: { value: 'bar' } } } would return ['bar']\n return example.value\n })\n\n // returns the first example as selected value along other examples\n return { value: exampleValues[0], examples: exampleValues }\n }\n\n // param example e.g. { example: 'foo' }\n if (isDefined(param.example)) {\n return { value: param.example }\n }\n\n // param examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(param.examples) && param.examples.length > 0) {\n return { value: param.examples[0] }\n }\n\n // schema example e.g. { example: 'foo' } while being discouraged\n // see https://spec.openapis.org/oas/v3.1.1.html#fixed-fields-20\n if (isDefined(schema?.example)) {\n return { value: schema.example }\n }\n\n // schema examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(schema?.examples) && schema.examples.length > 0) {\n // For boolean type, default to false when using schema examples\n if (schema?.type === 'boolean') {\n return { value: schema.default ?? false }\n }\n return { value: schema.examples[0] }\n }\n\n // content examples e.g. { content: { 'application/json': { examples: { foo: { value: 'bar' } } } } }\n if (param.content) {\n const firstContentType = objectKeys(param.content)[0]\n if (firstContentType) {\n const content = (param.content as ParameterContent)[firstContentType]\n if (content?.examples) {\n const firstExampleKey = Object.keys(content.examples)[0]\n if (firstExampleKey) {\n const example = content.examples[firstExampleKey]\n if (isDefined(example?.value)) {\n return { value: example.value }\n }\n }\n }\n // content example e.g. { example: 'foo' }\n if (isDefined(content?.example)) {\n return { value: content.example }\n }\n }\n }\n\n return null\n })() as null | { value: any; examples?: string[] }\n\n /**\n * TODO:\n * - Need better value defaulting here\n * - Need to handle non-string parameters much better\n * - Need to handle unions/array values for schema\n */\n const value = String(firstExample?.value ?? schema?.default ?? '')\n\n // Handle non-string enums and enums within items for array types\n const parseEnum = (() => {\n if (schema?.enum && schema?.type !== 'string') {\n return schema.enum?.map(String)\n }\n\n if (schema?.items?.enum && schema?.type === 'array') {\n return schema.items.enum.map(String)\n }\n\n return schema?.enum\n })()\n\n // Handle parameter examples\n const examples =\n firstExample?.examples ||\n (schema?.examples && schema?.type !== 'string' ? schema.examples?.map(String) : schema?.examples)\n\n // safe parse the example\n const example = schemaModel(\n {\n ...schema,\n key: param.name,\n value,\n description: param.description,\n required: param.required,\n /** Initialized all required properties to enabled */\n enabled: !!param.required,\n enum: parseEnum,\n examples,\n },\n requestExampleParametersSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${param.name} is invalid.`)\n return requestExampleParametersSchema.parse({})\n }\n\n return example\n}\n\n/**\n * Create new request example from a request\n * Iterates the name of the example if provided\n */\nexport function createExampleFromRequest(request: Request, name: string, server?: Server): RequestExample {\n // ---------------------------------------------------------------------------\n // Populate all parameters with an example value\n const parameters: Record<'path' | 'cookie' | 'header' | 'query' | 'headers', RequestExampleParameter[]> = {\n path: [],\n query: [],\n cookie: [],\n // deprecated TODO: add zod transform to remove\n header: [],\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n }\n\n // Populated the separated params\n request.parameters?.forEach((p) => parameters[p.in].push(createParamInstance(p)))\n\n // TODO: add zod transform to remove header and only support headers\n if (parameters.header.length > 0) {\n parameters.headers = parameters.header\n parameters.header = []\n }\n\n // Get content type header\n const contentTypeHeader = parameters.headers.find((h) => h.key.toLowerCase() === 'content-type')\n\n // ---------------------------------------------------------------------------\n // Handle request body defaulting for various content type encodings\n const body: ExampleRequestBody = {\n activeBody: 'raw',\n }\n\n // If we have a request body or a content type header\n // TODO: we don't even handle path parameters here\n if (request.requestBody || contentTypeHeader?.value) {\n const requestBody = getRequestBodyFromOperation({\n information: {\n parameters: request.parameters ?? [],\n requestBody: request.requestBody,\n },\n })\n\n const contentType = request.requestBody ? requestBody?.mimeType : contentTypeHeader?.value\n\n // Handle JSON and JSON-like mimetypes\n if (contentType?.includes('/json') || contentType?.endsWith('+json')) {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'json',\n mimeType: contentType,\n value: requestBody?.text ?? JSON.stringify({}),\n }\n }\n\n if (contentType === 'application/xml') {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'xml',\n value: requestBody?.text ?? '',\n }\n }\n\n /**\n * TODO: Are we loading example files from somewhere based on the spec?\n * How are we handling the body values\n */\n if (contentType === 'application/octet-stream') {\n body.activeBody = 'binary'\n body.binary = undefined\n }\n\n if (contentType === 'application/x-www-form-urlencoded' || contentType === 'multipart/form-data') {\n body.activeBody = 'formData'\n body.formData = {\n encoding: contentType === 'application/x-www-form-urlencoded' ? 'urlencoded' : 'form-data',\n value: (requestBody?.params || []).map((param) => {\n if (param.value instanceof File) {\n return {\n key: param.name,\n value: 'BINARY',\n file: param.value,\n enabled: true,\n }\n }\n return {\n key: param.name,\n value: param.value || '',\n enabled: true,\n }\n }),\n }\n }\n\n // Add the content-type header if it doesn't exist and if it's not multipart request\n if (requestBody?.mimeType && !contentTypeHeader && !requestBody.mimeType.startsWith('multipart/')) {\n parameters.headers.push({\n key: 'Content-Type',\n value: requestBody.mimeType,\n enabled: true,\n })\n }\n }\n\n const serverVariables = server ? getServerVariableExamples(server) : {}\n\n // safe parse the example\n const example = schemaModel(\n {\n requestUid: request.uid,\n parameters,\n name,\n body,\n serverVariables,\n },\n requestExampleSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${request.uid} is invalid.`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CAAC,CAAC;AAAA,EACtC;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import { schemaModel } from '@/helpers/schema-model'\nimport { getServerVariableExamples } from '@/spec-getters/get-server-variable-examples'\nimport { keysOf } from '@scalar/object-utils/arrays'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nimport { getRequestBodyFromOperation } from '@/spec-getters/get-request-body-from-operation'\nimport { isDefined } from '@scalar/helpers/array/is-defined'\nimport { objectKeys } from '@scalar/helpers/object/object-keys'\nimport type { ParameterContent, RequestParameter } from './parameters'\nimport type { Request } from './requests'\nimport type { Server } from './server'\n\n// ---------------------------------------------------------------------------\n// Example Parameters\n\n/**\n * TODO: Deprecate this.\n *\n * The request schema should be stored in the request and any\n * parameters should be validated against that\n */\nexport const requestExampleParametersSchema = z\n .object({\n key: z.string().default(''),\n value: z.coerce.string().default(''),\n enabled: z.boolean().default(true),\n file: z.any().optional(),\n description: z.string().optional(),\n required: z.boolean().optional(),\n enum: z.array(z.string()).optional(),\n examples: z.array(z.any()).optional(),\n type: z\n .union([\n // 'string'\n z.string(),\n // ['string', 'null']\n z.array(z.string()),\n ])\n .optional(),\n format: z.string().optional(),\n minimum: z.number().optional(),\n maximum: z.number().optional(),\n default: z.any().optional(),\n nullable: z.boolean().optional(),\n })\n // set nullable: to true if type is ['string', 'null']\n .transform((_data) => {\n const data = { ..._data }\n\n // type: ['string', 'null'] -> nullable: true\n if (Array.isArray(data.type) && data.type.includes('null')) {\n data.nullable = true\n }\n\n // Hey, if it's just one value and 'null', we can make it a string and ditch the 'null'.\n if (Array.isArray(data.type) && data.type.length === 2 && data.type.includes('null')) {\n data.type = data.type.find((item) => item !== 'null')\n }\n\n return data\n })\n\n/** Convert the array of parameters to an object keyed by the parameter name */\nexport const parameterArrayToObject = (params: RequestExampleParameter[]) =>\n params.reduce<Record<string, string>>((map, param) => {\n map[param.key] = param.value\n return map\n }, {})\n\n/** Request examples - formerly known as instances - are \"children\" of requests */\nexport type RequestExampleParameter = z.infer<typeof requestExampleParametersSchema>\n\nexport const xScalarFileValueSchema = z\n .object({\n url: z.string(),\n base64: z.string().optional(),\n })\n .nullable()\n\n/**\n * When files are required for an example we provide the options\n * to provide a public URL or a base64 encoded string\n */\nexport type XScalarFileValue = z.infer<typeof xScalarFileValueSchema>\n\n/**\n * Schema for the OAS serialization of request example parameters\n *\n * File values can be optionally fetched on import OR inserted as a base64 encoded string\n */\nexport const xScalarFormDataValue = z.union([\n z.object({\n type: z.literal('string'),\n value: z.string(),\n }),\n z.object({\n type: z.literal('file'),\n file: xScalarFileValueSchema,\n }),\n])\n\nexport type XScalarFormDataValue = z.infer<typeof xScalarFormDataValue>\n\n// ---------------------------------------------------------------------------\n// Example Body\n\n/**\n * Possible encodings for example request bodies when using text formats\n *\n * TODO: This list may not be comprehensive enough\n */\nexport const exampleRequestBodyEncoding = ['json', 'text', 'html', 'javascript', 'xml', 'yaml', 'edn'] as const\n\nexport type BodyEncoding = (typeof exampleRequestBodyEncoding)[number]\n\nexport const exampleBodyMime = [\n 'application/json',\n 'text/plain',\n 'text/html',\n 'application/javascript',\n 'application/xml',\n 'application/yaml',\n 'application/edn',\n 'application/octet-stream',\n 'application/x-www-form-urlencoded',\n 'multipart/form-data',\n /** Used for direct files */\n 'binary',\n] as const\n\nexport type BodyMime = (typeof exampleBodyMime)[number]\n\nconst contentMapping: Record<BodyEncoding, BodyMime> = {\n json: 'application/json',\n text: 'text/plain',\n html: 'text/html',\n javascript: 'application/javascript',\n xml: 'application/xml',\n yaml: 'application/yaml',\n edn: 'application/edn',\n} as const\n\n/**\n * TODO: Migrate away from this layout to the format used in the extension\n *\n * If a user changes the encoding of the body we expect the content to change as well\n */\nexport const exampleRequestBodySchema = z.object({\n raw: z\n .object({\n encoding: z.enum(exampleRequestBodyEncoding),\n value: z.string().default(''),\n mimeType: z.string().optional(),\n })\n .optional(),\n formData: z\n .object({\n encoding: z.union([z.literal('form-data'), z.literal('urlencoded')]).default('form-data'),\n value: requestExampleParametersSchema.array().default([]),\n })\n .optional(),\n binary: z.instanceof(Blob).optional(),\n activeBody: z.union([z.literal('raw'), z.literal('formData'), z.literal('binary')]).default('raw'),\n})\n\nexport type ExampleRequestBody = z.infer<typeof exampleRequestBodySchema>\n\n/** Schema for the OAS serialization of request example bodies */\nexport const xScalarExampleBodySchema = z.object({\n encoding: z.enum(exampleBodyMime),\n /**\n * Body content as an object with a separately specified encoding or a simple pre-encoded string value\n *\n * Ideally we would convert any objects into the proper encoding on import\n */\n content: z.union([z.record(z.string(), z.any()), z.string()]),\n /** When the encoding is `binary` this will be used to link to the file */\n file: xScalarFileValueSchema.optional(),\n})\n\nexport type XScalarExampleBody = z.infer<typeof xScalarExampleBodySchema>\n\n// ---------------------------------------------------------------------------\n// Example Schema\n\nexport const requestExampleSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['EXAMPLE']>(),\n type: z.literal('requestExample').optional().default('requestExample'),\n requestUid: z.string().brand<ENTITY_BRANDS['OPERATION']>().optional(),\n name: z.string().optional().default('Name'),\n body: exampleRequestBodySchema.optional().default({}),\n parameters: z\n .object({\n path: requestExampleParametersSchema.array().default([]),\n query: requestExampleParametersSchema.array().default([]),\n headers: requestExampleParametersSchema.array().default([{ key: 'Accept', value: '*/*', enabled: true }]),\n cookies: requestExampleParametersSchema.array().default([]),\n })\n .optional()\n .default({}),\n /** TODO: Should this be deprecated? */\n serverVariables: z.record(z.string(), z.array(z.string())).optional(),\n})\n\nexport type RequestExample = z.infer<typeof requestExampleSchema>\n\n/** For OAS serialization we just store the simple key/value pairs */\nconst xScalarExampleParameterSchema = z.record(z.string(), z.string()).optional()\n\n/** Schema for the OAS serialization of request examples */\nexport const xScalarExampleSchema = z.object({\n /** TODO: Should this be required? */\n name: z.string().optional(),\n body: xScalarExampleBodySchema.optional(),\n parameters: z.object({\n path: xScalarExampleParameterSchema,\n query: xScalarExampleParameterSchema,\n headers: xScalarExampleParameterSchema,\n cookies: xScalarExampleParameterSchema,\n }),\n})\n\nexport type XScalarExample = z.infer<typeof xScalarExampleSchema>\n\n/**\n * Convert a request example to the xScalar serialized format\n *\n * TODO: The base format should be migrated to align MUCH closer to the serialized format\n */\nexport function convertExampleToXScalar(example: RequestExample) {\n const active = example.body?.activeBody\n\n const xScalarBody: XScalarExampleBody = {\n encoding: 'text/plain',\n content: '',\n }\n\n if (example.body?.activeBody === 'binary') {\n xScalarBody.encoding = 'binary'\n // TODO: Need to allow users to set these properties\n xScalarBody.file = null\n }\n\n if (active === 'formData' && example.body?.[active]) {\n const body = example.body[active]\n xScalarBody.encoding = body.encoding === 'form-data' ? 'multipart/form-data' : 'application/x-www-form-urlencoded'\n\n // TODO: Need to allow users to set these properties\n xScalarBody.content = body.value.reduce<Record<string, XScalarFormDataValue>>((map, param) => {\n /** TODO: We need to ensure only file or value is set */\n map[param.key] = param.file\n ? {\n type: 'file',\n file: null,\n }\n : {\n type: 'string',\n value: param.value,\n }\n return map\n }, {})\n }\n\n if (example.body?.activeBody === 'raw') {\n xScalarBody.encoding = contentMapping[example.body.raw?.encoding ?? 'text'] ?? 'text/plain'\n\n xScalarBody.content = example.body.raw?.value ?? ''\n }\n\n const parameters: XScalarExample['parameters'] = {}\n\n keysOf(example.parameters ?? {}).forEach((key) => {\n if (example.parameters?.[key].length) {\n parameters[key] = parameterArrayToObject(example.parameters[key])\n }\n })\n\n return xScalarExampleSchema.parse({\n /** Only add the body if we have content or the body should be a file */\n body: xScalarBody.content || xScalarBody.encoding === 'binary' ? xScalarBody : undefined,\n parameters,\n })\n}\n\n// ---------------------------------------------------------------------------\n// Example Helpers\n\n/** Create new instance parameter from a request parameter */\nexport function createParamInstance(param: RequestParameter) {\n const schema = param.schema as any\n\n const firstExample = (() => {\n if (param.examples && !Array.isArray(param.examples) && objectKeys(param.examples).length > 0) {\n const exampleValues = Object.entries(param.examples).map(([_, example]) => {\n // returns the external value if it exists\n if (example.externalValue) {\n return example.externalValue\n }\n\n // returns the value if it exists and is defined\n // e.g. { examples: { foo: { value: 'bar' } } } would return ['bar']\n return example.value\n })\n\n // returns the first example as selected value along other examples\n return { value: exampleValues[0], examples: exampleValues }\n }\n\n // param example e.g. { example: 'foo' }\n if (isDefined(param.example)) {\n return { value: param.example }\n }\n\n // param examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(param.examples) && param.examples.length > 0) {\n return { value: param.examples[0] }\n }\n\n // schema example e.g. { example: 'foo' } while being discouraged\n // see https://spec.openapis.org/oas/v3.1.1.html#fixed-fields-20\n if (isDefined(schema?.example)) {\n return { value: schema.example }\n }\n\n // schema examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(schema?.examples) && schema.examples.length > 0) {\n // For boolean type, default to false when using schema examples\n if (schema?.type === 'boolean') {\n return { value: schema.default ?? false }\n }\n return { value: schema.examples[0] }\n }\n\n // content examples e.g. { content: { 'application/json': { examples: { foo: { value: 'bar' } } } } }\n if (param.content) {\n const firstContentType = objectKeys(param.content)[0]\n if (firstContentType) {\n const content = (param.content as ParameterContent)[firstContentType]\n if (content?.examples) {\n const firstExampleKey = Object.keys(content.examples)[0]\n if (firstExampleKey) {\n const example = content.examples[firstExampleKey]\n if (isDefined(example?.value)) {\n return { value: example.value }\n }\n }\n }\n // content example e.g. { example: 'foo' }\n if (isDefined(content?.example)) {\n return { value: content.example }\n }\n }\n }\n\n return null\n })() as null | { value: any; examples?: string[] }\n\n /**\n * TODO:\n * - Need better value defaulting here\n * - Need to handle non-string parameters much better\n * - Need to handle unions/array values for schema\n */\n const value = String(firstExample?.value ?? schema?.default ?? '')\n\n // Handle non-string enums and enums within items for array types\n const parseEnum = (() => {\n if (schema?.enum && schema?.type !== 'string') {\n return schema.enum?.map(String)\n }\n\n if (schema?.items?.enum && schema?.type === 'array') {\n return schema.items.enum.map(String)\n }\n\n return schema?.enum\n })()\n\n // Handle parameter examples\n const examples =\n firstExample?.examples ||\n (schema?.examples && schema?.type !== 'string' ? schema.examples?.map(String) : schema?.examples)\n\n // safe parse the example\n const example = schemaModel(\n {\n ...schema,\n key: param.name,\n value,\n description: param.description,\n required: param.required,\n /** Initialized all required properties to enabled */\n enabled: !!param.required,\n enum: parseEnum,\n examples,\n },\n requestExampleParametersSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${param.name} is invalid.`)\n return requestExampleParametersSchema.parse({})\n }\n\n return example\n}\n\n/**\n * Create new request example from a request\n * Iterates the name of the example if provided\n */\nexport function createExampleFromRequest(request: Request, name: string, server?: Server): RequestExample {\n // ---------------------------------------------------------------------------\n // Populate all parameters with an example value\n const parameters: Record<'path' | 'cookie' | 'header' | 'query' | 'headers', RequestExampleParameter[]> = {\n path: [],\n query: [],\n cookie: [],\n // deprecated TODO: add zod transform to remove\n header: [],\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n }\n\n // Populated the separated params\n request.parameters?.forEach((p) => parameters[p.in].push(createParamInstance(p)))\n\n // TODO: add zod transform to remove header and only support headers\n if (parameters.header.length > 0) {\n parameters.headers = parameters.header\n parameters.header = []\n }\n\n // Get content type header\n const contentTypeHeader = parameters.headers.find((h) => h.key.toLowerCase() === 'content-type')\n\n // ---------------------------------------------------------------------------\n // Handle request body defaulting for various content type encodings\n const body: ExampleRequestBody = {\n activeBody: 'raw',\n }\n\n // If we have a request body or a content type header\n // TODO: we don't even handle path parameters here\n if (request.requestBody || contentTypeHeader?.value) {\n const requestBody = getRequestBodyFromOperation(request)\n\n const contentType = request.requestBody ? requestBody?.mimeType : contentTypeHeader?.value\n\n // Handle JSON and JSON-like mimetypes\n if (contentType?.includes('/json') || contentType?.endsWith('+json')) {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'json',\n mimeType: contentType,\n value: requestBody?.text ?? JSON.stringify({}),\n }\n }\n\n if (contentType === 'application/xml') {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'xml',\n value: requestBody?.text ?? '',\n }\n }\n\n /**\n * TODO: Are we loading example files from somewhere based on the spec?\n * How are we handling the body values\n */\n if (contentType === 'application/octet-stream') {\n body.activeBody = 'binary'\n body.binary = undefined\n }\n\n if (contentType === 'application/x-www-form-urlencoded' || contentType === 'multipart/form-data') {\n body.activeBody = 'formData'\n body.formData = {\n encoding: contentType === 'application/x-www-form-urlencoded' ? 'urlencoded' : 'form-data',\n value: (requestBody?.params || []).map((param) => {\n if (param.value instanceof File) {\n return {\n key: param.name,\n value: 'BINARY',\n file: param.value,\n enabled: true,\n }\n }\n return {\n key: param.name,\n value: param.value || '',\n enabled: true,\n }\n }),\n }\n }\n\n // Add the content-type header if it doesn't exist and if it's not multipart request\n if (requestBody?.mimeType && !contentTypeHeader && !requestBody.mimeType.startsWith('multipart/')) {\n parameters.headers.push({\n key: 'Content-Type',\n value: requestBody.mimeType,\n enabled: true,\n })\n }\n }\n\n const serverVariables = server ? getServerVariableExamples(server) : {}\n\n // safe parse the example\n const example = schemaModel(\n {\n requestUid: request.uid,\n parameters,\n name,\n body,\n serverVariables,\n },\n requestExampleSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${request.uid} is invalid.`)\n return requestExampleSchema.parse({})\n }\n return example\n}\n"],
5
+ "mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,iCAAiC;AAC1C,SAAS,cAAc;AACvB,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AAElB,SAAS,mCAAmC;AAC5C,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAcpB,MAAM,iCAAiC,EAC3C,OAAO;AAAA,EACN,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE;AAAA,EAC1B,OAAO,EAAE,OAAO,OAAO,EAAE,QAAQ,EAAE;AAAA,EACnC,SAAS,EAAE,QAAQ,EAAE,QAAQ,IAAI;AAAA,EACjC,MAAM,EAAE,IAAI,EAAE,SAAS;AAAA,EACvB,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC/B,MAAM,EAAE,MAAM,EAAE,OAAO,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AAAA,YACtB,SAAS;AAAA,UACX;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAGA,QAAI,aAAa,YAAY,CAAC,qBAAqB,CAAC,YAAY,SAAS,WAAW,YAAY,GAAG;AACjG,iBAAW,QAAQ,KAAK;AAAA,QACtB,KAAK;AAAA,QACL,OAAO,YAAY;AAAA,QACnB,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,kBAAkB,SAAS,0BAA0B,MAAM,IAAI,CAAC;AAGtE,QAAM,UAAU;AAAA,IACd;AAAA,MACE,YAAY,QAAQ;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,CAAC,SAAS;AACZ,YAAQ,KAAK,cAAc,QAAQ,GAAG,cAAc;AACpD,WAAO,qBAAqB,MAAM,CAAC,CAAC;AAAA,EACtC;AACA,SAAO;AACT;",
6
6
  "names": ["example"]
7
7
  }
@@ -108,10 +108,10 @@ export declare const oasRequestSchema: z.ZodObject<{
108
108
  summary?: string | undefined;
109
109
  externalValue?: string | undefined;
110
110
  }> | undefined;
111
+ schema?: unknown;
111
112
  content?: unknown;
112
113
  style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
113
114
  explode?: boolean | undefined;
114
- schema?: unknown;
115
115
  }, {
116
116
  name: string;
117
117
  in: "cookie" | "path" | "query" | "header";
@@ -124,10 +124,10 @@ export declare const oasRequestSchema: z.ZodObject<{
124
124
  summary?: string | undefined;
125
125
  externalValue?: string | undefined;
126
126
  }> | undefined;
127
+ schema?: unknown;
127
128
  content?: unknown;
128
129
  style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
129
130
  explode?: boolean | undefined;
130
- schema?: unknown;
131
131
  }>, "many">>;
132
132
  /**
133
133
  * External documentation object
@@ -171,14 +171,14 @@ export declare const oasRequestSchema: z.ZodObject<{
171
171
  }>>>;
172
172
  }, "strip", z.ZodTypeAny, {
173
173
  content: string | Record<string, any>;
174
- encoding: "binary" | "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
174
+ encoding: "binary" | "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data";
175
175
  file?: {
176
176
  url: string;
177
177
  base64?: string | undefined;
178
178
  } | null | undefined;
179
179
  }, {
180
180
  content: string | Record<string, any>;
181
- encoding: "binary" | "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
181
+ encoding: "binary" | "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data";
182
182
  file?: {
183
183
  url: string;
184
184
  base64?: string | undefined;
@@ -210,7 +210,7 @@ export declare const oasRequestSchema: z.ZodObject<{
210
210
  name?: string | undefined;
211
211
  body?: {
212
212
  content: string | Record<string, any>;
213
- encoding: "binary" | "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
213
+ encoding: "binary" | "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data";
214
214
  file?: {
215
215
  url: string;
216
216
  base64?: string | undefined;
@@ -226,7 +226,7 @@ export declare const oasRequestSchema: z.ZodObject<{
226
226
  name?: string | undefined;
227
227
  body?: {
228
228
  content: string | Record<string, any>;
229
- encoding: "binary" | "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
229
+ encoding: "binary" | "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data";
230
230
  file?: {
231
231
  url: string;
232
232
  base64?: string | undefined;
@@ -250,6 +250,7 @@ export declare const oasRequestSchema: z.ZodObject<{
250
250
  tags?: string[] | undefined;
251
251
  deprecated?: boolean | undefined;
252
252
  operationId?: string | undefined;
253
+ requestBody?: any;
253
254
  parameters?: {
254
255
  name: string;
255
256
  required: boolean;
@@ -262,12 +263,11 @@ export declare const oasRequestSchema: z.ZodObject<{
262
263
  summary?: string | undefined;
263
264
  externalValue?: string | undefined;
264
265
  }> | undefined;
266
+ schema?: unknown;
265
267
  content?: unknown;
266
268
  style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
267
269
  explode?: boolean | undefined;
268
- schema?: unknown;
269
270
  }[] | undefined;
270
- requestBody?: any;
271
271
  responses?: Record<string, any> | undefined;
272
272
  callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
273
273
  'x-scalar-examples'?: Record<string, {
@@ -280,7 +280,7 @@ export declare const oasRequestSchema: z.ZodObject<{
280
280
  name?: string | undefined;
281
281
  body?: {
282
282
  content: string | Record<string, any>;
283
- encoding: "binary" | "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
283
+ encoding: "binary" | "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data";
284
284
  file?: {
285
285
  url: string;
286
286
  base64?: string | undefined;
@@ -300,6 +300,7 @@ export declare const oasRequestSchema: z.ZodObject<{
300
300
  tags?: string[] | undefined;
301
301
  deprecated?: boolean | undefined;
302
302
  operationId?: string | undefined;
303
+ requestBody?: any;
303
304
  parameters?: {
304
305
  name: string;
305
306
  in: "cookie" | "path" | "query" | "header";
@@ -312,12 +313,11 @@ export declare const oasRequestSchema: z.ZodObject<{
312
313
  summary?: string | undefined;
313
314
  externalValue?: string | undefined;
314
315
  }> | undefined;
316
+ schema?: unknown;
315
317
  content?: unknown;
316
318
  style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
317
319
  explode?: boolean | undefined;
318
- schema?: unknown;
319
320
  }[] | undefined;
320
- requestBody?: any;
321
321
  responses?: Record<string, any> | undefined;
322
322
  callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
323
323
  'x-scalar-examples'?: Record<string, {
@@ -330,7 +330,7 @@ export declare const oasRequestSchema: z.ZodObject<{
330
330
  name?: string | undefined;
331
331
  body?: {
332
332
  content: string | Record<string, any>;
333
- encoding: "binary" | "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
333
+ encoding: "binary" | "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data";
334
334
  file?: {
335
335
  url: string;
336
336
  base64?: string | undefined;
@@ -413,10 +413,10 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
413
413
  summary?: string | undefined;
414
414
  externalValue?: string | undefined;
415
415
  }> | undefined;
416
+ schema?: unknown;
416
417
  content?: unknown;
417
418
  style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
418
419
  explode?: boolean | undefined;
419
- schema?: unknown;
420
420
  }, {
421
421
  name: string;
422
422
  in: "cookie" | "path" | "query" | "header";
@@ -429,10 +429,10 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
429
429
  summary?: string | undefined;
430
430
  externalValue?: string | undefined;
431
431
  }> | undefined;
432
+ schema?: unknown;
432
433
  content?: unknown;
433
434
  style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
434
435
  explode?: boolean | undefined;
435
- schema?: unknown;
436
436
  }>, "many">>;
437
437
  /**
438
438
  * External documentation object
@@ -476,14 +476,14 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
476
476
  }>>>;
477
477
  }, "strip", z.ZodTypeAny, {
478
478
  content: string | Record<string, any>;
479
- encoding: "binary" | "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
479
+ encoding: "binary" | "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data";
480
480
  file?: {
481
481
  url: string;
482
482
  base64?: string | undefined;
483
483
  } | null | undefined;
484
484
  }, {
485
485
  content: string | Record<string, any>;
486
- encoding: "binary" | "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
486
+ encoding: "binary" | "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data";
487
487
  file?: {
488
488
  url: string;
489
489
  base64?: string | undefined;
@@ -515,7 +515,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
515
515
  name?: string | undefined;
516
516
  body?: {
517
517
  content: string | Record<string, any>;
518
- encoding: "binary" | "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
518
+ encoding: "binary" | "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data";
519
519
  file?: {
520
520
  url: string;
521
521
  base64?: string | undefined;
@@ -531,7 +531,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
531
531
  name?: string | undefined;
532
532
  body?: {
533
533
  content: string | Record<string, any>;
534
- encoding: "binary" | "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
534
+ encoding: "binary" | "application/json" | "text/plain" | "text/html" | "application/javascript" | "application/xml" | "application/yaml" | "application/edn" | "application/octet-stream" | "application/x-www-form-urlencoded" | "multipart/form-data";
535
535
  file?: {
536
536
  url: string;
537
537
  base64?: string | undefined;
@@ -609,7 +609,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
609
609
  selectedServerUid: (string & z.BRAND<"server">) | null;
610
610
  servers: (string & z.BRAND<"server">)[];
611
611
  examples: (string & z.BRAND<"example">)[];
612
- method: "options" | "get" | "put" | "post" | "delete" | "head" | "patch" | "trace" | "connect";
612
+ method: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace";
613
613
  description?: string | undefined;
614
614
  summary?: string | undefined;
615
615
  externalDocs?: {
@@ -622,6 +622,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
622
622
  tags?: string[] | undefined;
623
623
  deprecated?: boolean | undefined;
624
624
  operationId?: string | undefined;
625
+ requestBody?: any;
625
626
  parameters?: {
626
627
  name: string;
627
628
  required: boolean;
@@ -634,16 +635,13 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
634
635
  summary?: string | undefined;
635
636
  externalValue?: string | undefined;
636
637
  }> | undefined;
638
+ schema?: unknown;
637
639
  content?: unknown;
638
640
  style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
639
641
  explode?: boolean | undefined;
640
- schema?: unknown;
641
642
  }[] | undefined;
642
- requestBody?: any;
643
643
  responses?: Record<string, any> | undefined;
644
644
  callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
645
- 'x-scalar-stability'?: XScalarStability | undefined;
646
- 'x-post-response'?: string | undefined;
647
645
  'x-codeSamples'?: {
648
646
  source: string;
649
647
  label?: string | undefined;
@@ -659,6 +657,8 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
659
657
  label?: string | undefined;
660
658
  lang?: string | undefined;
661
659
  }[] | undefined;
660
+ 'x-scalar-stability'?: XScalarStability | undefined;
661
+ 'x-post-response'?: string | undefined;
662
662
  }, {
663
663
  uid?: string | undefined;
664
664
  path?: string | undefined;
@@ -679,6 +679,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
679
679
  deprecated?: boolean | undefined;
680
680
  examples?: string[] | undefined;
681
681
  operationId?: string | undefined;
682
+ requestBody?: any;
682
683
  parameters?: {
683
684
  name: string;
684
685
  in: "cookie" | "path" | "query" | "header";
@@ -691,20 +692,19 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
691
692
  summary?: string | undefined;
692
693
  externalValue?: string | undefined;
693
694
  }> | undefined;
695
+ schema?: unknown;
694
696
  content?: unknown;
695
697
  style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
696
698
  explode?: boolean | undefined;
697
- schema?: unknown;
698
699
  }[] | undefined;
699
- requestBody?: any;
700
700
  responses?: Record<string, any> | undefined;
701
701
  callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
702
- 'x-scalar-stability'?: unknown;
703
- method?: "options" | "get" | "put" | "post" | "delete" | "head" | "patch" | "trace" | "connect" | undefined;
704
- 'x-post-response'?: string | undefined;
705
702
  'x-codeSamples'?: unknown;
706
703
  'x-code-samples'?: unknown;
707
704
  'x-custom-examples'?: unknown;
705
+ 'x-scalar-stability'?: unknown;
706
+ method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
707
+ 'x-post-response'?: string | undefined;
708
708
  }>;
709
709
  export type Request = z.infer<typeof requestSchema>;
710
710
  export type RequestPayload = z.input<typeof requestSchema>;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/entities/spec/server.ts"],
4
- "sourcesContent": ["import { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\n/**\n * Server Variable Object\n *\n * An object representing a Server Variable for server URL template substitution.\n *\n * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#server-variable-object\n */\nexport const oasServerVariableSchema = z.object({\n /**\n * An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty.\n */\n enum: z.array(z.string()).optional(),\n /**\n * REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.\n * Note this behavior is different than the Schema Object's treatment of default values, because in those cases\n * parameter values are optional. If the enum is defined, the value MUST exist in the enum's values.\n */\n default: z.string().optional(),\n /**\n * An optional description for the server variable. CommonMark syntax MAY be used for rich text representation.\n */\n description: z.string().optional(),\n})\n\n/** Extended schema for server variables */\nconst extendedServerVariableSchema = oasServerVariableSchema\n .extend({\n /** The value of the variable */\n value: z.string().optional(),\n })\n .refine((data) => {\n // Set default to the first enum value if invalid\n if (Array.isArray(data.enum) && !data.enum.includes(data.default ?? '') && data.enum.length > 0) {\n data.default = data.enum[0]\n }\n\n if (Array.isArray(data.enum) && data.enum.length === 0) {\n delete data.enum\n }\n\n // Always return true since we\u2019ve modified the data to be valid\n return true\n })\n\n/**\n * Server Object\n *\n * An object representing a Server.\n *\n * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#server-object\n */\nexport const oasServerSchema = z.object({\n /**\n * REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that\n * the host location is relative to the location where the OpenAPI document is being served. Variable substitutions\n * will be made when a variable is named in {brackets}.\n */\n url: z.string(),\n /**\n * An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text\n * representation.\n */\n description: z.string().optional(),\n /** A map between a variable name and its value. The value is used for substitution in the server's URL template. */\n variables: z.record(z.string(), extendedServerVariableSchema).optional(),\n})\n\nexport const serverSchema = oasServerSchema.extend({\n uid: nanoidSchema.brand<ENTITY_BRANDS['SERVER']>(),\n})\n\nexport type Server = z.infer<typeof serverSchema>\nexport type ServerPayload = z.input<typeof serverSchema>\n"],
4
+ "sourcesContent": ["import { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\n/**\n * Server Variable Object\n *\n * An object representing a Server Variable for server URL template substitution.\n *\n * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#server-variable-object\n */\nexport const oasServerVariableSchema = z.object({\n /**\n * An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty.\n */\n enum: z.array(z.string()).optional(),\n /**\n * REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.\n * Note this behavior is different than the Schema Object's treatment of default values, because in those cases\n * parameter values are optional. If the enum is defined, the value MUST exist in the enum's values.\n */\n default: z.string().optional(),\n /**\n * An optional description for the server variable. CommonMark syntax MAY be used for rich text representation.\n */\n description: z.string().optional(),\n})\n\n/** Extended schema for server variables */\nconst extendedServerVariableSchema = oasServerVariableSchema\n .extend({\n /** The value of the variable */\n value: z.string().optional(),\n })\n .refine((data) => {\n // Set default to the first enum value if invalid\n if (Array.isArray(data.enum) && !data.enum.includes(data.default ?? '') && data.enum.length > 0) {\n data.default = data.enum[0]\n }\n\n if (Array.isArray(data.enum) && data.enum.length === 0) {\n delete data.enum\n }\n\n // Always return true since we've modified the data to be valid\n return true\n })\n\n/**\n * Server Object\n *\n * An object representing a Server.\n *\n * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#server-object\n */\nexport const oasServerSchema = z.object({\n /**\n * REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that\n * the host location is relative to the location where the OpenAPI document is being served. Variable substitutions\n * will be made when a variable is named in {brackets}.\n */\n url: z.string(),\n /**\n * An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text\n * representation.\n */\n description: z.string().optional(),\n /** A map between a variable name and its value. The value is used for substitution in the server's URL template. */\n variables: z.record(z.string(), extendedServerVariableSchema).optional(),\n})\n\nexport const serverSchema = oasServerSchema.extend({\n uid: nanoidSchema.brand<ENTITY_BRANDS['SERVER']>(),\n})\n\nexport type Server = z.infer<typeof serverSchema>\nexport type ServerPayload = z.input<typeof serverSchema>\n"],
5
5
  "mappings": "AAAA,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AASX,MAAM,0BAA0B,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA,EAI9C,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnC,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,EAI7B,aAAa,EAAE,OAAO,EAAE,SAAS;AACnC,CAAC;AAGD,MAAM,+BAA+B,wBAClC,OAAO;AAAA;AAAA,EAEN,OAAO,EAAE,OAAO,EAAE,SAAS;AAC7B,CAAC,EACA,OAAO,CAAC,SAAS;AAEhB,MAAI,MAAM,QAAQ,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,KAAK,WAAW,EAAE,KAAK,KAAK,KAAK,SAAS,GAAG;AAC/F,SAAK,UAAU,KAAK,KAAK,CAAC;AAAA,EAC5B;AAEA,MAAI,MAAM,QAAQ,KAAK,IAAI,KAAK,KAAK,KAAK,WAAW,GAAG;AACtD,WAAO,KAAK;AAAA,EACd;AAGA,SAAO;AACT,CAAC;AASI,MAAM,kBAAkB,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtC,KAAK,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKd,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAEjC,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,4BAA4B,EAAE,SAAS;AACzE,CAAC;AAEM,MAAM,eAAe,gBAAgB,OAAO;AAAA,EACjD,KAAK,aAAa,MAA+B;AACnD,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/helpers/fetch-document.ts"],
4
- "sourcesContent": ["import { formatJsonOrYamlString } from './parse'\nimport { redirectToProxy } from './redirect-to-proxy'\n\n// Doesn\u2019t work\nconst OLD_PROXY_URL = 'https://api.scalar.com/request-proxy'\n// Does work\nconst NEW_PROXY_URL = 'https://proxy.scalar.com'\n\n/**\n * Fetches an OpenAPI/Swagger document from a given URL\n *\n * @throws an error if the fetch fails\n */\nexport async function fetchDocument(url: string, proxyUrl?: string, prettyPrint = true): Promise<string> {\n // This replaces the OLD_PROXY_URL with the NEW_PROXY_URL on the fly.\n if (proxyUrl === OLD_PROXY_URL) {\n // biome-ignore lint/style/noParameterAssign: It\u2019s ok, let\u2019s make an exception here.\n proxyUrl = NEW_PROXY_URL\n }\n\n const response = await fetch(redirectToProxy(proxyUrl, url))\n\n // Looks like the request failed\n if (response.status !== 200) {\n console.error(`[fetchDocument] Failed to fetch the OpenAPI document from ${url} (Status: ${response.status})`)\n\n if (!proxyUrl) {\n console.warn(\n `[fetchDocument] Tried to fetch the OpenAPI document from ${url} without a proxy. Are the CORS headers configured to allow cross-domain requests? https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS`,\n )\n }\n\n throw new Error(`Failed to fetch the OpenAPI document from ${url} (Status: ${response.status})`)\n }\n\n // If it\u2019s JSON, make it pretty\n if (prettyPrint) {\n return formatJsonOrYamlString(await response.text())\n }\n\n return await response.text()\n}\n"],
4
+ "sourcesContent": ["import { formatJsonOrYamlString } from './parse'\nimport { redirectToProxy } from './redirect-to-proxy'\n\n// Doesn't work\nconst OLD_PROXY_URL = 'https://api.scalar.com/request-proxy'\n// Does work\nconst NEW_PROXY_URL = 'https://proxy.scalar.com'\n\n/**\n * Fetches an OpenAPI/Swagger document from a given URL\n *\n * @throws an error if the fetch fails\n */\nexport async function fetchDocument(url: string, proxyUrl?: string, prettyPrint = true): Promise<string> {\n // This replaces the OLD_PROXY_URL with the NEW_PROXY_URL on the fly.\n if (proxyUrl === OLD_PROXY_URL) {\n // biome-ignore lint/style/noParameterAssign: It's ok, let's make an exception here.\n proxyUrl = NEW_PROXY_URL\n }\n\n const response = await fetch(redirectToProxy(proxyUrl, url))\n\n // Looks like the request failed\n if (response.status !== 200) {\n console.error(`[fetchDocument] Failed to fetch the OpenAPI document from ${url} (Status: ${response.status})`)\n\n if (!proxyUrl) {\n console.warn(\n `[fetchDocument] Tried to fetch the OpenAPI document from ${url} without a proxy. Are the CORS headers configured to allow cross-domain requests? https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS`,\n )\n }\n\n throw new Error(`Failed to fetch the OpenAPI document from ${url} (Status: ${response.status})`)\n }\n\n // If it's JSON, make it pretty\n if (prettyPrint) {\n return formatJsonOrYamlString(await response.text())\n }\n\n return await response.text()\n}\n"],
5
5
  "mappings": "AAAA,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAGhC,MAAM,gBAAgB;AAEtB,MAAM,gBAAgB;AAOtB,eAAsB,cAAc,KAAa,UAAmB,cAAc,MAAuB;AAEvG,MAAI,aAAa,eAAe;AAE9B,eAAW;AAAA,EACb;AAEA,QAAM,WAAW,MAAM,MAAM,gBAAgB,UAAU,GAAG,CAAC;AAG3D,MAAI,SAAS,WAAW,KAAK;AAC3B,YAAQ,MAAM,6DAA6D,GAAG,aAAa,SAAS,MAAM,GAAG;AAE7G,QAAI,CAAC,UAAU;AACb,cAAQ;AAAA,QACN,4DAA4D,GAAG;AAAA,MACjE;AAAA,IACF;AAEA,UAAM,IAAI,MAAM,6CAA6C,GAAG,aAAa,SAAS,MAAM,GAAG;AAAA,EACjG;AAGA,MAAI,aAAa;AACf,WAAO,uBAAuB,MAAM,SAAS,KAAK,CAAC;AAAA,EACrD;AAEA,SAAO,MAAM,SAAS,KAAK;AAC7B;",
6
6
  "names": []
7
7
  }
@@ -1,27 +1,30 @@
1
- import type { OpenAPIV3_1 } from '@scalar/openapi-types';
2
1
  import type { HttpMethod } from '@scalar/helpers/http/http-methods';
3
2
  import type { Request as HarRequest } from 'har-format';
3
+ import type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/path-operations';
4
+ import { type Dereference } from '@scalar/workspace-store/schemas/v3.1/type-guard';
5
+ import type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/server';
6
+ import type { SecuritySchemeObject } from '@scalar/workspace-store/schemas/v3.1/strict/security-scheme';
4
7
  export type OperationToHarProps = {
5
8
  /** OpenAPI Operation object */
6
- operation: OpenAPIV3_1.OperationObject;
9
+ operation: Dereference<OperationObject>;
7
10
  /** HTTP method of the operation */
8
11
  method: HttpMethod;
12
+ /** Path of the operation */
13
+ path: string;
14
+ /**
15
+ * requestBody.content[contentType].example to use for the request, it should be pre-selected and discriminated
16
+ */
17
+ example?: unknown;
9
18
  /**
10
19
  * Content type of the request
11
20
  *
12
21
  * @defaults to the first content type in the operation.requestBody.content
13
22
  */
14
23
  contentType?: string;
15
- /** Path of the operation */
16
- path: string;
17
24
  /** OpenAPI Server object */
18
- server?: OpenAPIV3_1.ServerObject;
25
+ server?: ServerObject | undefined;
19
26
  /** OpenAPI SecurityScheme objects which are applicable to the operation */
20
- securitySchemes?: OpenAPIV3_1.SecuritySchemeObject[];
21
- /**
22
- * requestBody.content[contentType].example to use for the request, it should be pre-selected and discriminated
23
- */
24
- example?: unknown;
27
+ securitySchemes?: SecuritySchemeObject[];
25
28
  };
26
29
  /**
27
30
  * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.
@@ -1 +1 @@
1
- {"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../src/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAOvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,WAAW,CAAC,eAAe,CAAA;IACtC,mCAAmC;IACnC,MAAM,EAAE,UAAU,CAAA;IAClB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,4BAA4B;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAC,YAAY,CAAA;IACjC,2EAA2E;IAC3E,eAAe,CAAC,EAAE,WAAW,CAAC,oBAAoB,EAAE,CAAA;IACpD;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,gFAQxB,mBAAmB,KAAG,UA+CxB,CAAA"}
1
+ {"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../src/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAMvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6DAA6D,CAAA;AAClG,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,iDAAiD,CAAA;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAA;AACtF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAA;AAEvG,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,WAAW,CAAC,eAAe,CAAC,CAAA;IACvC,mCAAmC;IACnC,MAAM,EAAE,UAAU,CAAA;IAClB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;IACjC,2EAA2E;IAC3E,eAAe,CAAC,EAAE,oBAAoB,EAAE,CAAA;CACzC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,gFAQxB,mBAAmB,KAAG,UAwDxB,CAAA"}
@@ -2,6 +2,7 @@ import { processServerUrl } from "./process-server-url.js";
2
2
  import { processParameters } from "./process-parameters.js";
3
3
  import { processBody } from "./process-body.js";
4
4
  import { processSecuritySchemes } from "./process-security-schemes.js";
5
+ import { isReference } from "@scalar/workspace-store/schemas/v3.1/type-guard";
5
6
  const operationToHar = ({
6
7
  operation,
7
8
  contentType,
@@ -26,15 +27,22 @@ const operationToHar = ({
26
27
  harRequest.url = processServerUrl(server, path);
27
28
  }
28
29
  if (operation.parameters) {
29
- const { url, headers, queryString } = processParameters(harRequest, operation.parameters, example);
30
+ const { url, headers, queryString, cookies } = processParameters(harRequest, operation.parameters, example);
30
31
  harRequest.url = url;
31
32
  harRequest.headers = headers;
32
33
  harRequest.queryString = queryString;
34
+ harRequest.cookies = cookies;
33
35
  }
34
- if (operation.requestBody?.content && example) {
36
+ if (!isReference(operation.requestBody) && operation.requestBody?.content) {
35
37
  const postData = processBody({ operation, contentType, example });
36
38
  harRequest.postData = postData;
37
39
  harRequest.bodySize = postData.text?.length ?? -1;
40
+ if (postData.mimeType && !harRequest.headers.some((header) => header.name.toLowerCase() === "content-type")) {
41
+ harRequest.headers.push({
42
+ name: "Content-Type",
43
+ value: postData.mimeType
44
+ });
45
+ }
38
46
  }
39
47
  if (securitySchemes) {
40
48
  const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/helpers/operation-to-har/operation-to-har.ts"],
4
- "sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { processServerUrl } from './process-server-url'\nimport { processParameters } from './process-parameters'\nimport { processBody } from './process-body'\nimport { processSecuritySchemes } from './process-security-schemes'\n\nexport type OperationToHarProps = {\n /** OpenAPI Operation object */\n operation: OpenAPIV3_1.OperationObject\n /** HTTP method of the operation */\n method: HttpMethod\n /**\n * Content type of the request\n *\n * @defaults to the first content type in the operation.requestBody.content\n */\n contentType?: string\n /** Path of the operation */\n path: string\n /** OpenAPI Server object */\n server?: OpenAPIV3_1.ServerObject\n /** OpenAPI SecurityScheme objects which are applicable to the operation */\n securitySchemes?: OpenAPIV3_1.SecuritySchemeObject[]\n /**\n * requestBody.content[contentType].example to use for the request, it should be pre-selected and discriminated\n */\n example?: unknown\n}\n\n/**\n * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.\n *\n * This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,\n * which can be used to generate code snippets for various programming languages and HTTP clients.\n *\n * The conversion handles:\n * - Server URL processing and path parameter substitution\n * - Query parameter formatting based on OpenAPI parameter styles\n * - Request body processing with content type handling\n * - Security scheme integration (API keys, etc.)\n *\n * The resulting HarRequest object follows the HAR specification and includes:\n * - HTTP method and URL\n * - Headers and query parameters\n * - Request body (if present)\n * - Cookie information\n * - Size calculations for headers and body\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const operationToHar = ({\n operation,\n contentType,\n method,\n path,\n server,\n securitySchemes,\n example,\n}: OperationToHarProps): HarRequest => {\n // Initialize the HAR request with basic properties\n const harRequest: HarRequest = {\n method,\n url: path,\n headers: [],\n queryString: [],\n postData: undefined,\n httpVersion: 'HTTP/1.1',\n cookies: [],\n headersSize: -1,\n bodySize: -1,\n }\n\n // Server URL\n if (server?.url) {\n harRequest.url = processServerUrl(server, path)\n }\n\n // Handle parameters\n if (operation.parameters) {\n const { url, headers, queryString } = processParameters(harRequest, operation.parameters, example)\n harRequest.url = url\n harRequest.headers = headers\n harRequest.queryString = queryString\n }\n\n // Handle request body\n if (operation.requestBody?.content && example) {\n const postData = processBody({ operation, contentType, example })\n harRequest.postData = postData\n harRequest.bodySize = postData.text?.length ?? -1\n }\n\n // Handle security schemes\n if (securitySchemes) {\n const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes)\n harRequest.headers.push(...headers)\n harRequest.queryString.push(...queryString)\n harRequest.cookies.push(...cookies)\n }\n\n // Calculate headers size\n const headerText = harRequest.headers.map((h) => `${h.name}: ${h.value}`).join('\\r\\n')\n harRequest.headersSize = headerText.length\n\n return harRequest\n}\n"],
5
- "mappings": "AAIA,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AA+ChC,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAuC;AAErC,QAAM,aAAyB;AAAA,IAC7B;AAAA,IACA,KAAK;AAAA,IACL,SAAS,CAAC;AAAA,IACV,aAAa,CAAC;AAAA,IACd,UAAU;AAAA,IACV,aAAa;AAAA,IACb,SAAS,CAAC;AAAA,IACV,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAGA,MAAI,QAAQ,KAAK;AACf,eAAW,MAAM,iBAAiB,QAAQ,IAAI;AAAA,EAChD;AAGA,MAAI,UAAU,YAAY;AACxB,UAAM,EAAE,KAAK,SAAS,YAAY,IAAI,kBAAkB,YAAY,UAAU,YAAY,OAAO;AACjG,eAAW,MAAM;AACjB,eAAW,UAAU;AACrB,eAAW,cAAc;AAAA,EAC3B;AAGA,MAAI,UAAU,aAAa,WAAW,SAAS;AAC7C,UAAM,WAAW,YAAY,EAAE,WAAW,aAAa,QAAQ,CAAC;AAChE,eAAW,WAAW;AACtB,eAAW,WAAW,SAAS,MAAM,UAAU;AAAA,EACjD;AAGA,MAAI,iBAAiB;AACnB,UAAM,EAAE,SAAS,aAAa,QAAQ,IAAI,uBAAuB,eAAe;AAChF,eAAW,QAAQ,KAAK,GAAG,OAAO;AAClC,eAAW,YAAY,KAAK,GAAG,WAAW;AAC1C,eAAW,QAAQ,KAAK,GAAG,OAAO;AAAA,EACpC;AAGA,QAAM,aAAa,WAAW,QAAQ,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,MAAM;AACrF,aAAW,cAAc,WAAW;AAEpC,SAAO;AACT;",
4
+ "sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { processServerUrl } from './process-server-url'\nimport { processParameters } from './process-parameters'\nimport { processBody } from './process-body'\nimport { processSecuritySchemes } from './process-security-schemes'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/path-operations'\nimport { isReference, type Dereference } from '@scalar/workspace-store/schemas/v3.1/type-guard'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/server'\nimport type { SecuritySchemeObject } from '@scalar/workspace-store/schemas/v3.1/strict/security-scheme'\n\nexport type OperationToHarProps = {\n /** OpenAPI Operation object */\n operation: Dereference<OperationObject>\n /** HTTP method of the operation */\n method: HttpMethod\n /** Path of the operation */\n path: string\n /**\n * requestBody.content[contentType].example to use for the request, it should be pre-selected and discriminated\n */\n example?: unknown\n /**\n * Content type of the request\n *\n * @defaults to the first content type in the operation.requestBody.content\n */\n contentType?: string\n /** OpenAPI Server object */\n server?: ServerObject | undefined\n /** OpenAPI SecurityScheme objects which are applicable to the operation */\n securitySchemes?: SecuritySchemeObject[]\n}\n\n/**\n * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.\n *\n * This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,\n * which can be used to generate code snippets for various programming languages and HTTP clients.\n *\n * The conversion handles:\n * - Server URL processing and path parameter substitution\n * - Query parameter formatting based on OpenAPI parameter styles\n * - Request body processing with content type handling\n * - Security scheme integration (API keys, etc.)\n *\n * The resulting HarRequest object follows the HAR specification and includes:\n * - HTTP method and URL\n * - Headers and query parameters\n * - Request body (if present)\n * - Cookie information\n * - Size calculations for headers and body\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const operationToHar = ({\n operation,\n contentType,\n method,\n path,\n server,\n securitySchemes,\n example,\n}: OperationToHarProps): HarRequest => {\n // Initialize the HAR request with basic properties\n const harRequest: HarRequest = {\n method,\n url: path,\n headers: [],\n queryString: [],\n postData: undefined,\n httpVersion: 'HTTP/1.1',\n cookies: [],\n headersSize: -1,\n bodySize: -1,\n }\n\n // Server URL\n if (server?.url) {\n harRequest.url = processServerUrl(server, path)\n }\n\n // Handle parameters\n if (operation.parameters) {\n const { url, headers, queryString, cookies } = processParameters(harRequest, operation.parameters, example)\n harRequest.url = url\n harRequest.headers = headers\n harRequest.queryString = queryString\n harRequest.cookies = cookies\n }\n\n // Handle request body\n if (!isReference(operation.requestBody) && operation.requestBody?.content) {\n const postData = processBody({ operation, contentType, example })\n harRequest.postData = postData\n harRequest.bodySize = postData.text?.length ?? -1\n\n // Add Content-Type header if not already present\n if (postData.mimeType && !harRequest.headers.some((header) => header.name.toLowerCase() === 'content-type')) {\n harRequest.headers.push({\n name: 'Content-Type',\n value: postData.mimeType,\n })\n }\n }\n\n // Handle security schemes\n if (securitySchemes) {\n const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes)\n harRequest.headers.push(...headers)\n harRequest.queryString.push(...queryString)\n harRequest.cookies.push(...cookies)\n }\n\n // Calculate headers size\n const headerText = harRequest.headers.map((h) => `${h.name}: ${h.value}`).join('\\r\\n')\n harRequest.headersSize = headerText.length\n\n return harRequest\n}\n"],
5
+ "mappings": "AAGA,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AAEvC,SAAS,mBAAqC;AAiDvC,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAuC;AAErC,QAAM,aAAyB;AAAA,IAC7B;AAAA,IACA,KAAK;AAAA,IACL,SAAS,CAAC;AAAA,IACV,aAAa,CAAC;AAAA,IACd,UAAU;AAAA,IACV,aAAa;AAAA,IACb,SAAS,CAAC;AAAA,IACV,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAGA,MAAI,QAAQ,KAAK;AACf,eAAW,MAAM,iBAAiB,QAAQ,IAAI;AAAA,EAChD;AAGA,MAAI,UAAU,YAAY;AACxB,UAAM,EAAE,KAAK,SAAS,aAAa,QAAQ,IAAI,kBAAkB,YAAY,UAAU,YAAY,OAAO;AAC1G,eAAW,MAAM;AACjB,eAAW,UAAU;AACrB,eAAW,cAAc;AACzB,eAAW,UAAU;AAAA,EACvB;AAGA,MAAI,CAAC,YAAY,UAAU,WAAW,KAAK,UAAU,aAAa,SAAS;AACzE,UAAM,WAAW,YAAY,EAAE,WAAW,aAAa,QAAQ,CAAC;AAChE,eAAW,WAAW;AACtB,eAAW,WAAW,SAAS,MAAM,UAAU;AAG/C,QAAI,SAAS,YAAY,CAAC,WAAW,QAAQ,KAAK,CAAC,WAAW,OAAO,KAAK,YAAY,MAAM,cAAc,GAAG;AAC3G,iBAAW,QAAQ,KAAK;AAAA,QACtB,MAAM;AAAA,QACN,OAAO,SAAS;AAAA,MAClB,CAAC;AAAA,IACH;AAAA,EACF;AAGA,MAAI,iBAAiB;AACnB,UAAM,EAAE,SAAS,aAAa,QAAQ,IAAI,uBAAuB,eAAe;AAChF,eAAW,QAAQ,KAAK,GAAG,OAAO;AAClC,eAAW,YAAY,KAAK,GAAG,WAAW;AAC1C,eAAW,QAAQ,KAAK,GAAG,OAAO;AAAA,EACpC;AAGA,QAAM,aAAa,WAAW,QAAQ,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,MAAM;AACrF,aAAW,cAAc,WAAW;AAEpC,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import type { OperationToHarProps } from '../../helpers/operation-to-har/operation-to-har.js';
2
2
  import type { PostData } from 'har-format';
3
- type ProcessBodyProps = Pick<OperationToHarProps, 'contentType' | 'operation'> & Required<Pick<OperationToHarProps, 'example'>>;
3
+ type ProcessBodyProps = Pick<OperationToHarProps, 'contentType' | 'operation' | 'example'>;
4
4
  /**
5
5
  * Processes the request body and returns the processed data
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"process-body.d.ts","sourceRoot":"","sources":["../../../src/helpers/operation-to-har/process-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACtF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,KAAK,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,aAAa,GAAG,WAAW,CAAC,GAC5E,QAAQ,CAAC,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC,CAAA;AAEhD;;GAEG;AACH,eAAO,MAAM,WAAW,wCAAyC,gBAAgB,KAAG,QAQnF,CAAA"}
1
+ {"version":3,"file":"process-body.d.ts","sourceRoot":"","sources":["../../../src/helpers/operation-to-har/process-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AAGtF,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEjD,KAAK,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,aAAa,GAAG,WAAW,GAAG,SAAS,CAAC,CAAA;AA0F1F;;GAEG;AACH,eAAO,MAAM,WAAW,wCAAyC,gBAAgB,KAAG,QA4CnF,CAAA"}