@scalar/oas-utils
Advanced tools
Comparing version 0.2.6 to 0.2.7
# @scalar/oas-utils | ||
## 0.2.7 | ||
### Patch Changes | ||
- 7f4d22e: refactor: new redirectToProxy helper | ||
## 0.2.6 | ||
@@ -4,0 +10,0 @@ |
@@ -10,2 +10,3 @@ import { z } from 'zod'; | ||
refUid: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>; | ||
required: z.ZodOptional<z.ZodBoolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
@@ -16,2 +17,3 @@ value: string; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -23,2 +25,3 @@ refUid?: string | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -37,2 +40,3 @@ file?: File | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -66,2 +70,3 @@ refUid?: string | undefined; | ||
refUid: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>; | ||
required: z.ZodOptional<z.ZodBoolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
@@ -72,2 +77,3 @@ value: string; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -79,2 +85,3 @@ refUid?: string | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -90,2 +97,3 @@ file?: File | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -100,2 +108,3 @@ refUid?: string | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -120,2 +129,3 @@ file?: File | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -138,2 +148,3 @@ refUid?: string | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -157,2 +168,3 @@ file?: File | undefined; | ||
refUid: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>; | ||
required: z.ZodOptional<z.ZodBoolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
@@ -163,2 +175,3 @@ value: string; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -170,2 +183,3 @@ refUid?: string | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -183,2 +197,3 @@ file?: File | undefined; | ||
refUid: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>; | ||
required: z.ZodOptional<z.ZodBoolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
@@ -189,2 +204,3 @@ value: string; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -196,2 +212,3 @@ refUid?: string | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -209,2 +226,3 @@ file?: File | undefined; | ||
refUid: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>; | ||
required: z.ZodOptional<z.ZodBoolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
@@ -215,2 +233,3 @@ value: string; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -222,2 +241,3 @@ refUid?: string | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -235,2 +255,3 @@ file?: File | undefined; | ||
refUid: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodString>>>; | ||
required: z.ZodOptional<z.ZodBoolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
@@ -241,2 +262,3 @@ value: string; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -248,2 +270,3 @@ refUid?: string | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -259,2 +282,3 @@ file?: File | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -268,2 +292,3 @@ refUid?: string | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -277,2 +302,3 @@ refUid?: string | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -286,2 +312,3 @@ refUid?: string | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -295,2 +322,3 @@ refUid?: string | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -304,2 +332,3 @@ file?: File | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -313,2 +342,3 @@ file?: File | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -322,2 +352,3 @@ file?: File | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -338,2 +369,3 @@ file?: File | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -347,2 +379,3 @@ refUid?: string | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -356,2 +389,3 @@ refUid?: string | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -365,2 +399,3 @@ refUid?: string | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -382,2 +417,3 @@ refUid?: string | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -401,2 +437,3 @@ refUid?: string | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -410,2 +447,3 @@ file?: File | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -419,2 +457,3 @@ file?: File | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -428,2 +467,3 @@ file?: File | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -444,2 +484,3 @@ file?: File | undefined; | ||
key?: string | undefined; | ||
required?: boolean | undefined; | ||
enabled?: boolean | undefined; | ||
@@ -469,2 +510,3 @@ file?: File | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -478,2 +520,3 @@ refUid?: string | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -487,2 +530,3 @@ refUid?: string | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -496,2 +540,3 @@ refUid?: string | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -513,2 +558,3 @@ refUid?: string | undefined; | ||
description?: string | undefined; | ||
required?: boolean | undefined; | ||
file?: File | undefined; | ||
@@ -515,0 +561,0 @@ refUid?: string | undefined; |
@@ -13,2 +13,3 @@ import { z } from 'zod'; | ||
refUid: nanoidSchema.optional(), | ||
required: z.boolean().optional(), | ||
}); | ||
@@ -15,0 +16,0 @@ /** Create request example parameter helper */ |
@@ -17,2 +17,4 @@ import { z } from 'zod'; | ||
proxyUrl: z.ZodOptional<z.ZodString>; | ||
/** Workspace level theme, we might move this to user level later */ | ||
themeId: z.ZodDefault<z.ZodOptional<z.ZodString>>; | ||
}, "strip", z.ZodTypeAny, { | ||
@@ -26,2 +28,3 @@ uid: string; | ||
cookieUids: string[]; | ||
themeId: string; | ||
proxyUrl?: string | undefined; | ||
@@ -37,2 +40,3 @@ }, { | ||
proxyUrl?: string | undefined; | ||
themeId?: string | undefined; | ||
}>; | ||
@@ -50,2 +54,3 @@ /** The base scalar workspace */ | ||
cookieUids: string[]; | ||
themeId: string; | ||
proxyUrl?: string | undefined; | ||
@@ -52,0 +57,0 @@ }; |
@@ -19,2 +19,4 @@ import { z } from 'zod'; | ||
proxyUrl: z.string().optional(), | ||
/** Workspace level theme, we might move this to user level later */ | ||
themeId: z.string().optional().default('default'), | ||
}); | ||
@@ -21,0 +23,0 @@ const createWorkspace = (payload) => workspaceSchema.parse(payload); |
@@ -0,1 +1,2 @@ | ||
import { redirectToProxy } from './redirectToProxy.js'; | ||
import { formatJsonOrYamlString } from './parse.js'; | ||
@@ -7,6 +8,2 @@ | ||
const NEW_PROXY_URL = 'https://proxy.scalar.com'; | ||
/** Redirects the request to a proxy server with a given URL. */ | ||
function redirectToProxy(proxy, url) { | ||
return `${proxy}?scalar_url=${encodeURIComponent(url)}`; | ||
} | ||
/** Fetches an OpenAPI/Swagger specification from a given URL. */ | ||
@@ -13,0 +10,0 @@ async function fetchSpecFromUrl(url, proxy) { |
@@ -14,2 +14,3 @@ export * from './concatenateUrlAndPath.js'; | ||
export * from './prettyPrintJson.js'; | ||
export * from './redirectToProxy.js'; | ||
export * from './replaceVariables.js'; | ||
@@ -16,0 +17,0 @@ export * from './schema-model.js'; |
@@ -14,2 +14,3 @@ export { concatenateUrlAndPath } from './concatenateUrlAndPath.js'; | ||
export { prettyPrintJson, replaceCircularDependencies } from './prettyPrintJson.js'; | ||
export { isRequestToLocalhost, redirectToProxy, shouldUseProxy } from './redirectToProxy.js'; | ||
export { replaceVariables } from './replaceVariables.js'; | ||
@@ -16,0 +17,0 @@ export { schemaModel } from './schema-model.js'; |
@@ -72,3 +72,4 @@ import { type Request } from '../entities/workspace/spec/index.js'; | ||
components: any; | ||
securityDefinitions: any; | ||
}>; | ||
//# sourceMappingURL=import-spec.d.ts.map |
@@ -118,4 +118,5 @@ import { tagObjectSchema } from '../entities/workspace/spec/spec.js'; | ||
// Select initial security | ||
const firstSecurityKey = Object.keys(parsedSpec.components?.securitySchemes ?? {})?.[0]; | ||
const firstScheme = parsedSpec.components?.securitySchemes?.[firstSecurityKey ?? '']; | ||
const firstSecurityKey = Object.keys((schema?.components?.securitySchemes || schema?.securityDefinitions) ?? {})?.[0]; | ||
const firstScheme = (schema?.components?.securitySchemes || | ||
schema?.securityDefinitions)?.[firstSecurityKey ?? '']; | ||
// In the case of oauth2 we need to select the flow as well | ||
@@ -130,5 +131,5 @@ const flowKey = firstScheme?.type === 'oauth2' | ||
spec: { | ||
openapi: parsedSpec.openapi, | ||
openapi: schema?.openapi, | ||
info: schema?.info, | ||
security: parsedSpec.security, | ||
security: schema?.security || schema?.securityDefinitions, | ||
externalDocs: schema?.externalDocs, | ||
@@ -144,2 +145,3 @@ serverUids: servers.map(({ uid }) => uid), | ||
const components = schema?.components; | ||
const securityDefinitions = schema?.securityDefinitions; | ||
return { | ||
@@ -152,2 +154,3 @@ tags, | ||
components, | ||
securityDefinitions, | ||
}; | ||
@@ -154,0 +157,0 @@ }; |
@@ -19,3 +19,3 @@ { | ||
], | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"engines": { | ||
@@ -22,0 +22,0 @@ "node": ">=18" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
223847
162
4851
15