@scalar/oas-utils 0.2.124 → 0.2.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/entities/spec/request-examples.d.ts +27 -27
- package/dist/entities/spec/spec-objects.d.ts.map +1 -1
- package/dist/entities/spec/spec-objects.js +8 -1
- package/dist/helpers/fetch-document.d.ts +7 -0
- package/dist/helpers/fetch-document.d.ts.map +1 -0
- package/dist/helpers/fetch-document.js +35 -0
- package/dist/helpers/fetch-with-proxy-fallback.d.ts +3 -3
- package/dist/helpers/fetch-with-proxy-fallback.d.ts.map +1 -1
- package/dist/helpers/fetch-with-proxy-fallback.js +6 -6
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/redirect-to-proxy.d.ts +15 -5
- package/dist/helpers/redirect-to-proxy.d.ts.map +1 -1
- package/dist/helpers/redirect-to-proxy.js +68 -23
- package/dist/spec-getters/get-example-from-schema.d.ts.map +1 -1
- package/dist/spec-getters/get-example-from-schema.js +12 -3
- package/dist/transforms/import-spec.d.ts +1 -1
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +1 -1
- package/package.json +6 -6
- package/dist/entities/spec/security.d.ts +0 -1436
- package/dist/entities/spec/security.d.ts.map +0 -1
- package/dist/entities/spec/security.js +0 -179
- package/dist/helpers/fetch-spec-from-url.d.ts +0 -7
- package/dist/helpers/fetch-spec-from-url.d.ts.map +0 -1
- package/dist/helpers/fetch-spec-from-url.js +0 -36
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Hard limit for rendering circular references */
|
|
2
2
|
const MAX_LEVELS_DEEP = 5;
|
|
3
|
+
/** Sets the max number of properties after the third level to prevent exponential horizontal growth */
|
|
4
|
+
const MAX_PROPERTIES = 10;
|
|
3
5
|
const genericExampleValues = {
|
|
4
6
|
// 'date-time': '1970-01-01T00:00:00Z',
|
|
5
7
|
'date-time': new Date().toISOString(),
|
|
@@ -118,15 +120,22 @@ const getExampleFromSchema = (schema, options, level = 0, parentSchema, name) =>
|
|
|
118
120
|
// Object
|
|
119
121
|
if (schema.type === 'object' || schema.properties !== undefined) {
|
|
120
122
|
const response = {};
|
|
123
|
+
let propertyCount = 0;
|
|
121
124
|
// Regular properties
|
|
122
125
|
if (schema.properties !== undefined) {
|
|
123
126
|
for (const propertyName in schema.properties) {
|
|
124
127
|
if (Object.prototype.hasOwnProperty.call(schema.properties, propertyName)) {
|
|
128
|
+
// Only apply property limit for nested levels (level > 0)
|
|
129
|
+
if (level > 3 && propertyCount >= MAX_PROPERTIES) {
|
|
130
|
+
response['...'] = '[Additional Properties Truncated]';
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
125
133
|
const property = schema.properties[propertyName];
|
|
126
134
|
const propertyXmlTagName = options?.xml ? property.xml?.name : undefined;
|
|
127
|
-
|
|
128
|
-
if (typeof
|
|
129
|
-
|
|
135
|
+
const value = getExampleFromSchema(property, options, level + 1, schema, propertyName);
|
|
136
|
+
if (typeof value !== 'undefined') {
|
|
137
|
+
response[propertyXmlTagName ?? propertyName] = value;
|
|
138
|
+
propertyCount++;
|
|
130
139
|
}
|
|
131
140
|
}
|
|
132
141
|
}
|
|
@@ -5,9 +5,9 @@ import type { SelectedSecuritySchemeUids } from '../entities/shared/utility.ts';
|
|
|
5
5
|
import { type Collection, type CollectionPayload } from '../entities/spec/collection.ts';
|
|
6
6
|
import { type RequestExample } from '../entities/spec/request-examples.ts';
|
|
7
7
|
import { type Request } from '../entities/spec/requests.ts';
|
|
8
|
-
import { type SecurityScheme } from '../entities/spec/security.ts';
|
|
9
8
|
import { type Server } from '../entities/spec/server.ts';
|
|
10
9
|
import { type Tag } from '../entities/spec/spec-objects.ts';
|
|
10
|
+
import { type SecurityScheme } from '@scalar/types/entities';
|
|
11
11
|
/** Takes a string or object and parses it into an openapi spec compliant schema */
|
|
12
12
|
export declare const parseSchema: (spec: string | UnknownObject, { shouldLoad }?: {
|
|
13
13
|
shouldLoad?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAC9E,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAoB,MAAM,+BAA+B,CAAA;AAEzG,OAAO,EAAE,KAAK,cAAc,EAA4B,MAAM,qCAAqC,CAAA;AACnG,OAAO,EAAE,KAAK,OAAO,EAAsC,MAAM,6BAA6B,CAAA;AAC9F,OAAO,
|
|
1
|
+
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAC9E,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAoB,MAAM,+BAA+B,CAAA;AAEzG,OAAO,EAAE,KAAK,cAAc,EAA4B,MAAM,qCAAqC,CAAA;AACnG,OAAO,EAAE,KAAK,OAAO,EAAsC,MAAM,6BAA6B,CAAA;AAC9F,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,KAAK,GAAG,EAAa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,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,eAAe,EAAE,cAAc,EAAE,CAAA;CAClC,GACD;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,SAAS,CAAA;CAAE,CACnE,CAyWA;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,WAAW,CAAC,YAAY,EAAE,GAAG,SAAS,EAC/C,EAAE,aAAa,EAAE,GAAE,IAAI,CAAC,yBAAyB,EAAE,eAAe,CAAM,GACvE,MAAM,EAAE,CA0CV"}
|
|
@@ -3,13 +3,13 @@ import { load, upgrade, dereference } from '@scalar/openapi-parser';
|
|
|
3
3
|
import { collectionSchema } from '../entities/spec/collection.js';
|
|
4
4
|
import { createExampleFromRequest } from '../entities/spec/request-examples.js';
|
|
5
5
|
import { requestSchema } from '../entities/spec/requests.js';
|
|
6
|
-
import { securitySchemeSchema } from '../entities/spec/security.js';
|
|
7
6
|
import { serverSchema } from '../entities/spec/server.js';
|
|
8
7
|
import { tagSchema } from '../entities/spec/spec-objects.js';
|
|
9
8
|
import { isHttpMethod } from '../helpers/http-methods.js';
|
|
10
9
|
import { isDefined } from '../helpers/is-defined.js';
|
|
11
10
|
import { combineUrlAndPath } from '../helpers/merge-urls.js';
|
|
12
11
|
import { schemaModel } from '../helpers/schema-model.js';
|
|
12
|
+
import { securitySchemeSchema } from '@scalar/types/entities';
|
|
13
13
|
|
|
14
14
|
/** Takes a string or object and parses it into an openapi spec compliant schema */
|
|
15
15
|
const parseSchema = async (spec, { shouldLoad = true } = {}) => {
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.126",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
"yaml": "^2.4.5",
|
|
89
89
|
"zod": "^3.23.8",
|
|
90
90
|
"@scalar/object-utils": "1.1.13",
|
|
91
|
-
"@scalar/
|
|
92
|
-
"@scalar/
|
|
93
|
-
"@scalar/types": "0.1.
|
|
91
|
+
"@scalar/themes": "0.9.84",
|
|
92
|
+
"@scalar/openapi-types": "0.2.0",
|
|
93
|
+
"@scalar/types": "0.1.6"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@types/node": "^20.17.10",
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
"vitest": "^1.6.0",
|
|
100
100
|
"zod-to-ts": "github:amritk/zod-to-ts#build",
|
|
101
101
|
"@scalar/build-tooling": "0.1.17",
|
|
102
|
-
"@scalar/openapi-parser": "0.10.
|
|
103
|
-
"@scalar/openapi-types": "0.
|
|
102
|
+
"@scalar/openapi-parser": "0.10.14",
|
|
103
|
+
"@scalar/openapi-types": "0.2.0"
|
|
104
104
|
},
|
|
105
105
|
"scripts": {
|
|
106
106
|
"build": "scalar-build-rollup",
|