Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@scalar/oas-utils

Package Overview
Dependencies
Maintainers
8
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scalar/oas-utils - npm Package Compare versions

Comparing version 0.2.39 to 0.2.41

16

CHANGELOG.md
# @scalar/oas-utils
## 0.2.41
### Patch Changes
- f931ac7: fix: displays variable in curly braces when empty
## 0.2.40
### Patch Changes
- 0afb293: feat: request bodies for multipart form data and url encoded form data
- e67f5a8: chore(api-client): removed axios dependency
- b63be39: fix: incorrect example for schemas with anyOf
- 152c016: feat: add environment selector to addressbar
- @scalar/types@0.0.6
## 0.2.39

@@ -4,0 +20,0 @@

2

dist/entities/workspace/spec/components.d.ts

@@ -1,3 +0,3 @@

import type { OpenAPIV3_1 } from '@scalar/openapi-parser';
import type { OpenAPIV3_1 } from '@scalar/openapi-types';
export type SchemaObject = OpenAPIV3_1.SchemaObject;
//# sourceMappingURL=components.d.ts.map

@@ -29,6 +29,6 @@ import { z } from 'zod';

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}, {

@@ -44,7 +44,7 @@ minimum?: number | undefined;

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}>;

@@ -66,6 +66,6 @@ /** Request examples - formerly known as instances - are "children" of requests */

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
};

@@ -83,6 +83,6 @@ declare const requestExampleSchema: z.ZodObject<{

value: string;
encoding: "json" | "text" | "html" | "javascript" | "xml" | "yaml" | "edn";
encoding: "xml" | "json" | "text" | "html" | "javascript" | "yaml" | "edn";
}, {
value?: string | undefined;
encoding?: "json" | "text" | "html" | "javascript" | "xml" | "yaml" | "edn" | undefined;
encoding?: "xml" | "json" | "text" | "html" | "javascript" | "yaml" | "edn" | undefined;
}>>;

@@ -118,6 +118,6 @@ formData: z.ZodDefault<z.ZodObject<{

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}, {

@@ -133,7 +133,7 @@ minimum?: number | undefined;

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}>, "many">>;

@@ -152,6 +152,6 @@ }, "strip", z.ZodTypeAny, {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -170,7 +170,7 @@ encoding: "form-data" | "urlencoded";

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[] | undefined;

@@ -184,3 +184,3 @@ encoding?: "form-data" | "urlencoded" | undefined;

value: string;
encoding: "json" | "text" | "html" | "javascript" | "xml" | "yaml" | "edn";
encoding: "xml" | "json" | "text" | "html" | "javascript" | "yaml" | "edn";
};

@@ -199,6 +199,6 @@ formData: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -212,3 +212,3 @@ encoding: "form-data" | "urlencoded";

value?: string | undefined;
encoding?: "json" | "text" | "html" | "javascript" | "xml" | "yaml" | "edn" | undefined;
encoding?: "xml" | "json" | "text" | "html" | "javascript" | "yaml" | "edn" | undefined;
} | undefined;

@@ -226,7 +226,7 @@ formData?: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[] | undefined;

@@ -266,6 +266,6 @@ encoding?: "form-data" | "urlencoded" | undefined;

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}, {

@@ -281,7 +281,7 @@ minimum?: number | undefined;

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}>, "many">>;

@@ -315,6 +315,6 @@ query: z.ZodDefault<z.ZodArray<z.ZodObject<{

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}, {

@@ -330,7 +330,7 @@ minimum?: number | undefined;

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}>, "many">>;

@@ -364,6 +364,6 @@ headers: z.ZodDefault<z.ZodArray<z.ZodObject<{

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}, {

@@ -379,7 +379,7 @@ minimum?: number | undefined;

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}>, "many">>;

@@ -413,6 +413,6 @@ cookies: z.ZodDefault<z.ZodArray<z.ZodObject<{

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}, {

@@ -428,7 +428,7 @@ minimum?: number | undefined;

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}>, "many">>;

@@ -447,6 +447,6 @@ }, "strip", z.ZodTypeAny, {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -464,6 +464,6 @@ query: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -481,6 +481,6 @@ headers: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -498,6 +498,6 @@ cookies: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -515,7 +515,7 @@ }, {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[] | undefined;

@@ -532,7 +532,7 @@ query?: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[] | undefined;

@@ -549,7 +549,7 @@ headers?: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[] | undefined;

@@ -566,7 +566,7 @@ cookies?: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[] | undefined;

@@ -583,3 +583,3 @@ }>>>;

value: string;
encoding: "json" | "text" | "html" | "javascript" | "xml" | "yaml" | "edn";
encoding: "xml" | "json" | "text" | "html" | "javascript" | "yaml" | "edn";
};

@@ -598,6 +598,6 @@ formData: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -621,6 +621,6 @@ encoding: "form-data" | "urlencoded";

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -638,6 +638,6 @@ query: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -655,6 +655,6 @@ headers: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -672,6 +672,6 @@ cookies: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -688,3 +688,3 @@ };

value?: string | undefined;
encoding?: "json" | "text" | "html" | "javascript" | "xml" | "yaml" | "edn" | undefined;
encoding?: "xml" | "json" | "text" | "html" | "javascript" | "yaml" | "edn" | undefined;
} | undefined;

@@ -702,7 +702,7 @@ formData?: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[] | undefined;

@@ -725,7 +725,7 @@ encoding?: "form-data" | "urlencoded" | undefined;

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[] | undefined;

@@ -742,7 +742,7 @@ query?: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[] | undefined;

@@ -759,7 +759,7 @@ headers?: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[] | undefined;

@@ -776,7 +776,7 @@ cookies?: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
enabled?: boolean | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[] | undefined;

@@ -798,3 +798,3 @@ } | undefined;

value: string;
encoding: "json" | "text" | "html" | "javascript" | "xml" | "yaml" | "edn";
encoding: "xml" | "json" | "text" | "html" | "javascript" | "yaml" | "edn";
};

@@ -813,6 +813,6 @@ formData: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -836,6 +836,6 @@ encoding: "form-data" | "urlencoded";

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -853,6 +853,6 @@ query: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -870,6 +870,6 @@ headers: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -887,6 +887,6 @@ cookies: {

enum?: string[] | undefined;
nullable?: boolean | undefined;
format?: string | undefined;
file?: any;
refUid?: string | undefined;
format?: string | undefined;
nullable?: boolean | undefined;
}[];

@@ -893,0 +893,0 @@ };

@@ -1,9 +0,14 @@

import type { OpenAPIV3_1 } from '@scalar/openapi-parser';
import type { AxiosResponse } from 'axios';
import type { OpenAPIV3_1 } from '@scalar/openapi-types';
import { z } from 'zod';
import type { RequestExample } from './request-examples.js';
/** A single set of populated values for a sent request */
export type ResponseInstance = AxiosResponse & {
export type ResponseInstance = Omit<Response, 'headers'> & {
/** Store headers as an object to match what we had with axios */
headers: Record<string, string>;
/** Keys of headers which set cookies */
cookieHeaderKeys: string[];
/** Time in ms the request took */
duration: number;
/** The response data */
data: unknown;
};

@@ -10,0 +15,0 @@ /** A single request/response set to save to the history stack */

@@ -52,2 +52,4 @@ import { z } from 'zod';

}>>;
/** Active Environment ID to use for requests */
activeEnvironmentId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
/** List of all cookie uids in a given workspace */

@@ -66,2 +68,3 @@ cookieUids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;

environmentUids: string[];
activeEnvironmentId: string;
cookieUids: string[];

@@ -91,2 +94,3 @@ themeId: "default" | "alternate" | "moon" | "purple" | "solarized" | "bluePlanet" | "deepSpace" | "saturn" | "kepler" | "mars" | "none";

} | undefined;
activeEnvironmentId?: string | undefined;
cookieUids?: string[] | undefined;

@@ -106,2 +110,3 @@ proxyUrl?: string | undefined;

environmentUids: string[];
activeEnvironmentId: string;
cookieUids: string[];

@@ -108,0 +113,0 @@ themeId: "default" | "alternate" | "moon" | "purple" | "solarized" | "bluePlanet" | "deepSpace" | "saturn" | "kepler" | "mars" | "none";

@@ -34,2 +34,4 @@ import { themeIds } from '@scalar/themes';

hotKeyConfig: hotKeyConfigSchema,
/** Active Environment ID to use for requests */
activeEnvironmentId: z.string().optional().default('default'),
/** List of all cookie uids in a given workspace */

@@ -36,0 +38,0 @@ cookieUids: z.array(z.string()).default([]),

@@ -13,3 +13,3 @@ /**

else {
return variablesOrCallback[match]?.toString();
return variablesOrCallback[match]?.toString() || `{${match}}`;
}

@@ -16,0 +16,0 @@ };

@@ -124,6 +124,6 @@ /**

if (schema.anyOf !== undefined) {
Object.assign(response, getExampleFromSchema(schema.anyOf[0]), options, level + 1);
Object.assign(response, getExampleFromSchema(schema.anyOf[0], options, level + 1));
}
else if (schema.oneOf !== undefined) {
Object.assign(response, getExampleFromSchema(schema.oneOf[0]), options, level + 1);
Object.assign(response, getExampleFromSchema(schema.oneOf[0], options, level + 1));
}

@@ -130,0 +130,0 @@ else if (schema.allOf !== undefined) {

@@ -42,6 +42,9 @@ import type { ContentType, TransformedOperation } from '@scalar/types/legacy';

mimeType: string;
params: {
name: string;
value: any;
}[];
text?: undefined;
params?: undefined;
};
} | undefined;
//# sourceMappingURL=getRequestBodyFromOperation.d.ts.map

@@ -8,2 +8,15 @@ import { json2xml } from '../helpers/json2xml.js';

/**
* Transform the object into a nested array of objects
* that represent the key-value pairs of the object.
*/
function getParamsFromObject(obj, prefix = '') {
return Object.entries(obj).flatMap(([key, value]) => {
const newKey = prefix ? `${prefix}[${key}]` : key;
if (typeof value === 'object' && value !== null) {
return getParamsFromObject(value, newKey);
}
return [{ name: newKey, value }];
});
}
/**
* Get the request body from the operation.

@@ -164,3 +177,11 @@ */

// URL encoded data
if (mimeType === 'application/x-www-form-urlencoded') {
if (mimeType === 'multipart/form-data' ||
mimeType === 'application/x-www-form-urlencoded') {
const exampleFromSchema = requestBodyObject?.schema
? getExampleFromSchema(requestBodyObject?.schema, {
xml: true,
mode: 'write',
omitEmptyAndOptionalProperties: true,
})
: null;
return {

@@ -170,30 +191,6 @@ headers,

mimeType: mimeType,
// TODO: We have an object, but how do we get that kind of array from the object?
// Don’t forget to include nested properties … :|
// params: [
// {
// name: 'foo',
// value: 'bar',
// },
// ],
params: getParamsFromObject(example ?? exampleFromSchema ?? {}),
},
};
}
// URL encoded data
if (mimeType === 'multipart/form-data') {
return {
headers,
postData: {
mimeType: mimeType,
// TODO: We have an object, but how do we get that kind of array from the object?
// Don’t forget to include nested properties … :|
// params: [
// {
// name: 'foo',
// value: 'bar',
// },
// ],
},
};
}
return undefined;

@@ -200,0 +197,0 @@ }

@@ -19,3 +19,3 @@ {

],
"version": "0.2.39",
"version": "0.2.41",
"engines": {

@@ -90,3 +90,2 @@ "node": ">=18"

"dependencies": {
"axios": "^1.6.8",
"nanoid": "^5.0.7",

@@ -97,7 +96,5 @@ "yaml": "^2.4.5",

"@scalar/themes": "0.9.28",
"@scalar/types": "0.0.5"
"@scalar/types": "0.0.6"
},
"devDependencies": {
"@scalar/openapi-parser": "^0.7.2",
"axios": "^1.6.8",
"rollup": "^4.16.4",

@@ -107,3 +104,5 @@ "type-fest": "^4.20.0",

"vitest": "^1.6.0",
"@scalar/build-tooling": "0.1.10"
"@scalar/build-tooling": "0.1.10",
"@scalar/openapi-parser": "0.8.1",
"@scalar/openapi-types": "0.1.0"
},

@@ -110,0 +109,0 @@ "scripts": {

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc