@gitbook/react-openapi 1.2.1 → 1.3.1
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 +35 -0
- package/dist/OpenAPICodeSample.jsx +7 -4
- package/dist/OpenAPIDisclosure.d.ts +1 -0
- package/dist/OpenAPIDisclosure.jsx +6 -3
- package/dist/OpenAPIDisclosureGroup.jsx +16 -15
- package/dist/OpenAPIRequestBody.jsx +7 -2
- package/dist/OpenAPIRequestBodyHeaderType.d.ts +8 -0
- package/dist/OpenAPIRequestBodyHeaderType.jsx +25 -0
- package/dist/OpenAPIResponse.d.ts +1 -1
- package/dist/OpenAPIResponse.jsx +20 -4
- package/dist/OpenAPIResponseExample.jsx +15 -3
- package/dist/OpenAPIResponses.jsx +6 -1
- package/dist/OpenAPISchema.d.ts +9 -2
- package/dist/OpenAPISchema.jsx +87 -91
- package/dist/OpenAPISchemaName.d.ts +1 -1
- package/dist/OpenAPISchemaName.jsx +5 -5
- package/dist/OpenAPISecurities.jsx +59 -1
- package/dist/OpenAPISelect.jsx +1 -0
- package/dist/OpenAPISpec.jsx +16 -1
- package/dist/OpenAPIWebhookExample.jsx +1 -1
- package/dist/StaticSection.jsx +1 -1
- package/dist/code-samples.js +6 -3
- package/dist/generateSchemaExample.js +19 -14
- package/dist/getDisclosureLabel.d.ts +7 -0
- package/dist/getDisclosureLabel.js +18 -0
- package/dist/schemas/OpenAPISchemaItem.d.ts +7 -0
- package/dist/schemas/OpenAPISchemaItem.jsx +16 -0
- package/dist/schemas/OpenAPISchemas.jsx +3 -9
- package/dist/translations/de.d.ts +7 -1
- package/dist/translations/de.js +10 -4
- package/dist/translations/en.d.ts +7 -1
- package/dist/translations/en.js +9 -3
- package/dist/translations/es.d.ts +7 -1
- package/dist/translations/es.js +10 -4
- package/dist/translations/fr.d.ts +7 -1
- package/dist/translations/fr.js +11 -5
- package/dist/translations/index.d.ts +63 -9
- package/dist/translations/ja.d.ts +7 -1
- package/dist/translations/ja.js +9 -3
- package/dist/translations/nl.d.ts +7 -1
- package/dist/translations/nl.js +9 -3
- package/dist/translations/no.d.ts +7 -1
- package/dist/translations/no.js +10 -4
- package/dist/translations/pt-br.d.ts +7 -1
- package/dist/translations/pt-br.js +10 -4
- package/dist/translations/zh.d.ts +7 -1
- package/dist/translations/zh.js +10 -4
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +38 -0
- package/package.json +2 -2
- package/src/OpenAPICodeSample.tsx +7 -6
- package/src/OpenAPIDisclosure.tsx +7 -3
- package/src/OpenAPIDisclosureGroup.tsx +49 -48
- package/src/OpenAPIRequestBody.tsx +11 -2
- package/src/OpenAPIRequestBodyHeaderType.tsx +36 -0
- package/src/OpenAPIResponse.tsx +37 -5
- package/src/OpenAPIResponseExample.tsx +46 -35
- package/src/OpenAPIResponses.tsx +4 -4
- package/src/OpenAPISchema.tsx +157 -130
- package/src/OpenAPISchemaName.tsx +10 -8
- package/src/OpenAPISecurities.tsx +111 -7
- package/src/OpenAPISelect.tsx +1 -1
- package/src/OpenAPISpec.tsx +21 -1
- package/src/OpenAPIWebhookExample.tsx +2 -2
- package/src/StaticSection.tsx +1 -1
- package/src/code-samples.test.ts +3 -2
- package/src/code-samples.ts +19 -12
- package/src/generateSchemaExample.test.ts +20 -0
- package/src/generateSchemaExample.ts +9 -1
- package/src/getDisclosureLabel.ts +25 -0
- package/src/schemas/OpenAPISchemaItem.tsx +34 -0
- package/src/schemas/OpenAPISchemas.tsx +7 -13
- package/src/translations/de.ts +10 -4
- package/src/translations/en.ts +9 -3
- package/src/translations/es.ts +10 -4
- package/src/translations/fr.ts +11 -5
- package/src/translations/ja.ts +9 -3
- package/src/translations/nl.ts +9 -3
- package/src/translations/no.ts +10 -4
- package/src/translations/pt-br.ts +10 -4
- package/src/translations/zh.ts +10 -4
- package/src/utils.ts +37 -0
|
@@ -10,17 +10,17 @@ export function OpenAPISchemaName(props) {
|
|
|
10
10
|
{propertyName ? (<span data-deprecated={schema === null || schema === void 0 ? void 0 : schema.deprecated} className="openapi-schema-propertyname">
|
|
11
11
|
{propertyName}
|
|
12
12
|
</span>) : null}
|
|
13
|
-
<span>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
{type || additionalItems ? (<span>
|
|
14
|
+
{type ? <span className="openapi-schema-type">{type}</span> : null}
|
|
15
|
+
{additionalItems ? (<span className="openapi-schema-type">{additionalItems}</span>) : null}
|
|
16
|
+
</span>) : null}
|
|
17
17
|
{(schema === null || schema === void 0 ? void 0 : schema.readOnly) ? (<span className="openapi-schema-readonly">
|
|
18
18
|
{t(context.translation, 'read_only')}
|
|
19
19
|
</span>) : null}
|
|
20
20
|
{(schema === null || schema === void 0 ? void 0 : schema.writeOnly) ? (<span className="openapi-schema-writeonly">
|
|
21
21
|
{t(context.translation, 'write_only')}
|
|
22
22
|
</span>) : null}
|
|
23
|
-
{required ? (<span className="openapi-schema-required">
|
|
23
|
+
{required === null ? null : required ? (<span className="openapi-schema-required">
|
|
24
24
|
{t(context.translation, 'required')}
|
|
25
25
|
</span>) : (<span className="openapi-schema-optional">
|
|
26
26
|
{t(context.translation, 'optional')}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InteractiveSection } from './InteractiveSection';
|
|
2
2
|
import { Markdown } from './Markdown';
|
|
3
|
+
import { OpenAPICopyButton } from './OpenAPICopyButton';
|
|
3
4
|
import { OpenAPISchemaName } from './OpenAPISchemaName';
|
|
4
5
|
import { t } from './translate';
|
|
5
6
|
import { createStateKey, resolveDescription } from './utils';
|
|
@@ -46,7 +47,7 @@ function getLabelForType(security, context) {
|
|
|
46
47
|
}
|
|
47
48
|
return (<OpenAPISchemaName context={context} propertyName="HTTP" required={security.required}/>);
|
|
48
49
|
case 'oauth2':
|
|
49
|
-
return
|
|
50
|
+
return <OpenAPISchemaOAuth2Flows context={context} security={security}/>;
|
|
50
51
|
case 'openIdConnect':
|
|
51
52
|
return (<OpenAPISchemaName context={context} propertyName="OpenID Connect" required={security.required}/>);
|
|
52
53
|
default:
|
|
@@ -54,3 +55,60 @@ function getLabelForType(security, context) {
|
|
|
54
55
|
return security.type;
|
|
55
56
|
}
|
|
56
57
|
}
|
|
58
|
+
function OpenAPISchemaOAuth2Flows(props) {
|
|
59
|
+
var _a;
|
|
60
|
+
var context = props.context, security = props.security;
|
|
61
|
+
var flows = Object.entries((_a = security.flows) !== null && _a !== void 0 ? _a : {});
|
|
62
|
+
return (<div className="openapi-securities-oauth-flows">
|
|
63
|
+
{flows.map(function (_a, index) {
|
|
64
|
+
var name = _a[0], flow = _a[1];
|
|
65
|
+
return (<OpenAPISchemaOAuth2Item key={index} flow={flow} name={name} context={context} security={security}/>);
|
|
66
|
+
})}
|
|
67
|
+
</div>);
|
|
68
|
+
}
|
|
69
|
+
function OpenAPISchemaOAuth2Item(props) {
|
|
70
|
+
var _a;
|
|
71
|
+
var flow = props.flow, context = props.context, security = props.security, name = props.name;
|
|
72
|
+
if (!flow) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
var scopes = Object.entries((_a = flow === null || flow === void 0 ? void 0 : flow.scopes) !== null && _a !== void 0 ? _a : {});
|
|
76
|
+
return (<div>
|
|
77
|
+
<OpenAPISchemaName context={context} propertyName="OAuth2" type={name} required={security.required}/>
|
|
78
|
+
<div className="openapi-securities-oauth-content openapi-markdown">
|
|
79
|
+
{security.description ? <Markdown source={security.description}/> : null}
|
|
80
|
+
{'authorizationUrl' in flow && flow.authorizationUrl ? (<span>
|
|
81
|
+
Authorization URL:{' '}
|
|
82
|
+
<OpenAPICopyButton value={flow.authorizationUrl} context={context} className="openapi-securities-url" withTooltip>
|
|
83
|
+
{flow.authorizationUrl}
|
|
84
|
+
</OpenAPICopyButton>
|
|
85
|
+
</span>) : null}
|
|
86
|
+
{'tokenUrl' in flow && flow.tokenUrl ? (<span>
|
|
87
|
+
Token URL:{' '}
|
|
88
|
+
<OpenAPICopyButton value={flow.tokenUrl} context={context} className="openapi-securities-url" withTooltip>
|
|
89
|
+
{flow.tokenUrl}
|
|
90
|
+
</OpenAPICopyButton>
|
|
91
|
+
</span>) : null}
|
|
92
|
+
{'refreshUrl' in flow && flow.refreshUrl ? (<span>
|
|
93
|
+
Refresh URL:{' '}
|
|
94
|
+
<OpenAPICopyButton value={flow.refreshUrl} context={context} className="openapi-securities-url" withTooltip>
|
|
95
|
+
{flow.refreshUrl}
|
|
96
|
+
</OpenAPICopyButton>
|
|
97
|
+
</span>) : null}
|
|
98
|
+
{scopes.length ? (<div>
|
|
99
|
+
{t(context.translation, 'available_scopes')}:{' '}
|
|
100
|
+
<ul>
|
|
101
|
+
{scopes.map(function (_a) {
|
|
102
|
+
var key = _a[0], value = _a[1];
|
|
103
|
+
return (<li key={key}>
|
|
104
|
+
<OpenAPICopyButton value={key} context={context} withTooltip>
|
|
105
|
+
<code>{key}</code>
|
|
106
|
+
</OpenAPICopyButton>
|
|
107
|
+
: {value}
|
|
108
|
+
</li>);
|
|
109
|
+
})}
|
|
110
|
+
</ul>
|
|
111
|
+
</div>) : null}
|
|
112
|
+
</div>
|
|
113
|
+
</div>);
|
|
114
|
+
}
|
package/dist/OpenAPISelect.jsx
CHANGED
|
@@ -6,6 +6,7 @@ import { useStore } from 'zustand';
|
|
|
6
6
|
import { getOrCreateStoreByKey } from './getOrCreateStoreByKey';
|
|
7
7
|
export function useSelectState(stateKey, initialKey) {
|
|
8
8
|
if (stateKey === void 0) { stateKey = 'select-state'; }
|
|
9
|
+
if (initialKey === void 0) { initialKey = 'default'; }
|
|
9
10
|
var store = useStore(getOrCreateStoreByKey(stateKey, initialKey));
|
|
10
11
|
return {
|
|
11
12
|
key: store.key,
|
package/dist/OpenAPISpec.jsx
CHANGED
|
@@ -9,7 +9,7 @@ export function OpenAPISpec(props) {
|
|
|
9
9
|
var _a;
|
|
10
10
|
var data = props.data, context = props.context;
|
|
11
11
|
var operation = data.operation;
|
|
12
|
-
var parameters = (_a = operation.parameters) !== null && _a !== void 0 ? _a : [];
|
|
12
|
+
var parameters = deduplicateParameters((_a = operation.parameters) !== null && _a !== void 0 ? _a : []);
|
|
13
13
|
var parameterGroups = groupParameters(parameters, context);
|
|
14
14
|
var securities = 'securities' in data ? data.securities : [];
|
|
15
15
|
return (<>
|
|
@@ -60,3 +60,18 @@ function getParameterGroupName(paramIn, context) {
|
|
|
60
60
|
return paramIn;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
/** Deduplicate parameters by name and in.
|
|
64
|
+
* Some specs have both parameters define at path and operation level.
|
|
65
|
+
* We only want to display one of them.
|
|
66
|
+
*/
|
|
67
|
+
function deduplicateParameters(parameters) {
|
|
68
|
+
var seen = new Set();
|
|
69
|
+
return parameters.filter(function (param) {
|
|
70
|
+
var key = "".concat(param.name, ":").concat(param.in);
|
|
71
|
+
if (seen.has(key)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
seen.add(key);
|
|
75
|
+
return true;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -12,7 +12,7 @@ export function OpenAPIWebhookExample(props) {
|
|
|
12
12
|
}
|
|
13
13
|
return Object.entries(operation.requestBody.content).map(function (_a) {
|
|
14
14
|
var key = _a[0], value = _a[1];
|
|
15
|
-
var schema = value.schema;
|
|
15
|
+
var schema = value === null || value === void 0 ? void 0 : value.schema;
|
|
16
16
|
if (!schema) {
|
|
17
17
|
return {
|
|
18
18
|
key: key,
|
package/dist/StaticSection.jsx
CHANGED
|
@@ -4,7 +4,7 @@ export function Section(props) {
|
|
|
4
4
|
return <div {...props} className={clsx('openapi-section', props.className)}/>;
|
|
5
5
|
}
|
|
6
6
|
export function SectionHeader(props) {
|
|
7
|
-
return (<div {...props} className={clsx('openapi-section-header', props.className
|
|
7
|
+
return (<div {...props} className={clsx('openapi-section-header', props.className ? "".concat(props.className, "-header") : undefined)}/>);
|
|
8
8
|
}
|
|
9
9
|
export function SectionHeaderContent(props) {
|
|
10
10
|
return (<div {...props} className={clsx('openapi-section-header-content', props.className && "".concat(props.className, "-header-content"))}/>);
|
package/dist/code-samples.js
CHANGED
|
@@ -16,7 +16,7 @@ export var codeSampleGenerators = [
|
|
|
16
16
|
{
|
|
17
17
|
id: 'http',
|
|
18
18
|
label: 'HTTP',
|
|
19
|
-
syntax: '
|
|
19
|
+
syntax: 'http',
|
|
20
20
|
generate: function (_a) {
|
|
21
21
|
var method = _a.method, url = _a.url, _b = _a.headers, headers = _b === void 0 ? {} : _b, body = _a.body;
|
|
22
22
|
var _c = parseHostAndPath(url), host = _c.host, path = _c.path;
|
|
@@ -340,12 +340,15 @@ var BodyGenerators = {
|
|
|
340
340
|
return '$$__TRUE__$$';
|
|
341
341
|
case false:
|
|
342
342
|
return '$$__FALSE__$$';
|
|
343
|
+
case null:
|
|
344
|
+
return '$$__NULL__$$';
|
|
343
345
|
default:
|
|
344
346
|
return value;
|
|
345
347
|
}
|
|
346
|
-
})
|
|
348
|
+
}, 2)
|
|
347
349
|
.replaceAll('"$$__TRUE__$$"', 'True')
|
|
348
|
-
.replaceAll('"$$__FALSE__$$"', 'False')
|
|
350
|
+
.replaceAll('"$$__FALSE__$$"', 'False')
|
|
351
|
+
.replaceAll('"$$__NULL__$$"', 'None');
|
|
349
352
|
}
|
|
350
353
|
return { body: body, code: code, headers: headers };
|
|
351
354
|
},
|
|
@@ -101,7 +101,7 @@ function guessFromFormat(schema, fallback) {
|
|
|
101
101
|
*/
|
|
102
102
|
var getExampleFromSchema = function (schema, options, level, parentSchema, name, resultCache) {
|
|
103
103
|
var _a, _b, _c, _d;
|
|
104
|
-
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
104
|
+
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
105
105
|
if (level === void 0) { level = 0; }
|
|
106
106
|
if (resultCache === void 0) { resultCache = new WeakMap(); }
|
|
107
107
|
// Store result in the cache, and return the result
|
|
@@ -123,7 +123,7 @@ var getExampleFromSchema = function (schema, options, level, parentSchema, name,
|
|
|
123
123
|
// Fails if it contains a circular reference
|
|
124
124
|
JSON.stringify(schema);
|
|
125
125
|
}
|
|
126
|
-
catch (
|
|
126
|
+
catch (_w) {
|
|
127
127
|
return '[Circular Reference]';
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -131,7 +131,7 @@ var getExampleFromSchema = function (schema, options, level, parentSchema, name,
|
|
|
131
131
|
// But if `emptyString` is set, we do want to see some values.
|
|
132
132
|
var makeUpRandomData = !!(options === null || options === void 0 ? void 0 : options.emptyString);
|
|
133
133
|
// If the property is deprecated we don't show it in examples.
|
|
134
|
-
if (schema.deprecated) {
|
|
134
|
+
if (schema.deprecated || (schema.type === 'array' && ((_e = schema.items) === null || _e === void 0 ? void 0 : _e.deprecated))) {
|
|
135
135
|
return undefined;
|
|
136
136
|
}
|
|
137
137
|
// Check if the property is read-only/write-only
|
|
@@ -141,7 +141,7 @@ var getExampleFromSchema = function (schema, options, level, parentSchema, name,
|
|
|
141
141
|
}
|
|
142
142
|
// Use given variables as values
|
|
143
143
|
if (schema['x-variable']) {
|
|
144
|
-
var value = (
|
|
144
|
+
var value = (_f = options === null || options === void 0 ? void 0 : options.variables) === null || _f === void 0 ? void 0 : _f[schema['x-variable']];
|
|
145
145
|
// Return the value if it’s defined
|
|
146
146
|
if (value !== undefined) {
|
|
147
147
|
// Type-casting
|
|
@@ -159,6 +159,11 @@ var getExampleFromSchema = function (schema, options, level, parentSchema, name,
|
|
|
159
159
|
if (schema.example !== undefined) {
|
|
160
160
|
return cache(schema, schema.example);
|
|
161
161
|
}
|
|
162
|
+
// Use a default value, if there’s one and it’s a string or number
|
|
163
|
+
if (schema.default !== undefined &&
|
|
164
|
+
['string', 'number', 'boolean'].includes(typeof schema.default)) {
|
|
165
|
+
return cache(schema, schema.default);
|
|
166
|
+
}
|
|
162
167
|
// enum: [ 'available', 'pending', 'sold' ]
|
|
163
168
|
if (Array.isArray(schema.enum) && schema.enum.length > 0) {
|
|
164
169
|
return cache(schema, schema.enum[0]);
|
|
@@ -166,13 +171,13 @@ var getExampleFromSchema = function (schema, options, level, parentSchema, name,
|
|
|
166
171
|
// Check if the property is required
|
|
167
172
|
var isObjectOrArray = schema.type === 'object' ||
|
|
168
173
|
schema.type === 'array' ||
|
|
169
|
-
!!((
|
|
170
|
-
!!((
|
|
171
|
-
!!((
|
|
174
|
+
!!((_h = (_g = schema.allOf) === null || _g === void 0 ? void 0 : _g.at) === null || _h === void 0 ? void 0 : _h.call(_g, 0)) ||
|
|
175
|
+
!!((_k = (_j = schema.anyOf) === null || _j === void 0 ? void 0 : _j.at) === null || _k === void 0 ? void 0 : _k.call(_j, 0)) ||
|
|
176
|
+
!!((_m = (_l = schema.oneOf) === null || _l === void 0 ? void 0 : _l.at) === null || _m === void 0 ? void 0 : _m.call(_l, 0));
|
|
172
177
|
if (!isObjectOrArray && (options === null || options === void 0 ? void 0 : options.omitEmptyAndOptionalProperties) === true) {
|
|
173
178
|
var isRequired = schema.required === true ||
|
|
174
179
|
(parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.required) === true ||
|
|
175
|
-
((
|
|
180
|
+
((_o = parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.required) === null || _o === void 0 ? void 0 : _o.includes(name !== null && name !== void 0 ? name : schema.name));
|
|
176
181
|
if (!isRequired) {
|
|
177
182
|
return undefined;
|
|
178
183
|
}
|
|
@@ -185,7 +190,7 @@ var getExampleFromSchema = function (schema, options, level, parentSchema, name,
|
|
|
185
190
|
for (var propertyName in schema.properties) {
|
|
186
191
|
if (Object.prototype.hasOwnProperty.call(schema.properties, propertyName)) {
|
|
187
192
|
var property = schema.properties[propertyName];
|
|
188
|
-
var propertyXmlTagName = (options === null || options === void 0 ? void 0 : options.xml) ? (
|
|
193
|
+
var propertyXmlTagName = (options === null || options === void 0 ? void 0 : options.xml) ? (_p = property.xml) === null || _p === void 0 ? void 0 : _p.name : undefined;
|
|
189
194
|
response[propertyXmlTagName !== null && propertyXmlTagName !== void 0 ? propertyXmlTagName : propertyName] = getExampleFromSchema(property, options, level + 1, schema, propertyName, resultCache);
|
|
190
195
|
if (typeof response[propertyXmlTagName !== null && propertyXmlTagName !== void 0 ? propertyXmlTagName : propertyName] === 'undefined') {
|
|
191
196
|
delete response[propertyXmlTagName !== null && propertyXmlTagName !== void 0 ? propertyXmlTagName : propertyName];
|
|
@@ -236,8 +241,8 @@ var getExampleFromSchema = function (schema, options, level, parentSchema, name,
|
|
|
236
241
|
}
|
|
237
242
|
// Array
|
|
238
243
|
if (schema.type === 'array' || schema.items !== undefined) {
|
|
239
|
-
var itemsXmlTagName_1 = (
|
|
240
|
-
var wrapItems = !!((options === null || options === void 0 ? void 0 : options.xml) && ((
|
|
244
|
+
var itemsXmlTagName_1 = (_r = (_q = schema === null || schema === void 0 ? void 0 : schema.items) === null || _q === void 0 ? void 0 : _q.xml) === null || _r === void 0 ? void 0 : _r.name;
|
|
245
|
+
var wrapItems = !!((options === null || options === void 0 ? void 0 : options.xml) && ((_s = schema.xml) === null || _s === void 0 ? void 0 : _s.wrapped) && itemsXmlTagName_1);
|
|
241
246
|
if (schema.example !== undefined) {
|
|
242
247
|
return cache(schema, wrapItems ? (_a = {}, _a[itemsXmlTagName_1] = schema.example, _a) : schema.example);
|
|
243
248
|
}
|
|
@@ -279,7 +284,7 @@ var getExampleFromSchema = function (schema, options, level, parentSchema, name,
|
|
|
279
284
|
return cache(schema, wrapItems ? [(_c = {}, _c[itemsXmlTagName_1] = exampleFromRule, _c)] : exampleFromRule);
|
|
280
285
|
}
|
|
281
286
|
}
|
|
282
|
-
if ((
|
|
287
|
+
if ((_t = schema.items) === null || _t === void 0 ? void 0 : _t.type) {
|
|
283
288
|
var exampleFromSchema = getExampleFromSchema(schema.items, options, level + 1, undefined, undefined, resultCache);
|
|
284
289
|
return wrapItems ? [(_d = {}, _d[itemsXmlTagName_1] = exampleFromSchema, _d)] : [exampleFromSchema];
|
|
285
290
|
}
|
|
@@ -288,8 +293,8 @@ var getExampleFromSchema = function (schema, options, level, parentSchema, name,
|
|
|
288
293
|
var exampleValues = {
|
|
289
294
|
string: makeUpRandomData ? guessFromFormat(schema, options === null || options === void 0 ? void 0 : options.emptyString) : '',
|
|
290
295
|
boolean: true,
|
|
291
|
-
integer: (
|
|
292
|
-
number: (
|
|
296
|
+
integer: (_u = schema.min) !== null && _u !== void 0 ? _u : 1,
|
|
297
|
+
number: (_v = schema.min) !== null && _v !== void 0 ? _v : 1,
|
|
293
298
|
array: [],
|
|
294
299
|
};
|
|
295
300
|
if (schema.type !== undefined && exampleValues[schema.type] !== undefined) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
|
+
import type { OpenAPIClientContext } from './context';
|
|
3
|
+
export declare function getDisclosureLabel(props: {
|
|
4
|
+
schema: OpenAPIV3.SchemaObject;
|
|
5
|
+
isExpanded: boolean;
|
|
6
|
+
context: OpenAPIClientContext;
|
|
7
|
+
}): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { tString } from './translate';
|
|
3
|
+
export function getDisclosureLabel(props) {
|
|
4
|
+
var schema = props.schema, isExpanded = props.isExpanded, context = props.context;
|
|
5
|
+
var label;
|
|
6
|
+
if (schema.type === 'array' && !!schema.items) {
|
|
7
|
+
if (schema.items.oneOf) {
|
|
8
|
+
label = tString(context.translation, 'available_items').toLowerCase();
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
label = tString(context.translation, 'properties').toLowerCase();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
label = tString(context.translation, 'properties').toLowerCase();
|
|
16
|
+
}
|
|
17
|
+
return tString(context.translation, isExpanded ? 'hide' : 'show', label);
|
|
18
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
2
|
+
import type { OpenAPIClientContext } from '../context';
|
|
3
|
+
export declare function OpenAPISchemaItem(props: {
|
|
4
|
+
name: string;
|
|
5
|
+
schema: OpenAPIV3.SchemaObject;
|
|
6
|
+
context: OpenAPIClientContext;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { SectionBody } from '../StaticSection';
|
|
3
|
+
import { OpenAPIDisclosure } from '../OpenAPIDisclosure';
|
|
4
|
+
import { OpenAPIRootSchema } from '../OpenAPISchemaServer';
|
|
5
|
+
import { Section } from '../StaticSection';
|
|
6
|
+
import { getDisclosureLabel } from '../getDisclosureLabel';
|
|
7
|
+
export function OpenAPISchemaItem(props) {
|
|
8
|
+
var schema = props.schema, context = props.context, name = props.name;
|
|
9
|
+
return (<OpenAPIDisclosure className="openapi-schemas-disclosure" key={name} icon={context.icons.plus} header={name} label={function (isExpanded) { return getDisclosureLabel({ schema: schema, isExpanded: isExpanded, context: context }); }}>
|
|
10
|
+
<Section className="openapi-section-schemas">
|
|
11
|
+
<SectionBody>
|
|
12
|
+
<OpenAPIRootSchema schema={schema} context={context}/>
|
|
13
|
+
</SectionBody>
|
|
14
|
+
</Section>
|
|
15
|
+
</OpenAPIDisclosure>);
|
|
16
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import { OpenAPIDisclosure } from '../OpenAPIDisclosure';
|
|
3
2
|
import { OpenAPIExample } from '../OpenAPIExample';
|
|
4
3
|
import { OpenAPIRootSchema } from '../OpenAPISchemaServer';
|
|
5
|
-
import {
|
|
4
|
+
import { StaticSection } from '../StaticSection';
|
|
6
5
|
import { getOpenAPIClientContext, resolveOpenAPIContext, } from '../context';
|
|
7
6
|
import { t } from '../translate';
|
|
8
7
|
import { getExampleFromSchema } from '../util/example';
|
|
8
|
+
import { OpenAPISchemaItem } from './OpenAPISchemaItem';
|
|
9
9
|
/**
|
|
10
10
|
* OpenAPI Schemas component.
|
|
11
11
|
*/
|
|
@@ -53,13 +53,7 @@ export function OpenAPISchemas(props) {
|
|
|
53
53
|
return (<div className={clsx('openapi-schemas', className)}>
|
|
54
54
|
{schemas.map(function (_a) {
|
|
55
55
|
var name = _a.name, schema = _a.schema;
|
|
56
|
-
return (<
|
|
57
|
-
<Section className="openapi-section-schemas">
|
|
58
|
-
<SectionBody>
|
|
59
|
-
<OpenAPIRootSchema schema={schema} context={clientContext}/>
|
|
60
|
-
</SectionBody>
|
|
61
|
-
</Section>
|
|
62
|
-
</OpenAPIDisclosure>);
|
|
56
|
+
return (<OpenAPISchemaItem key={name} name={name} context={clientContext} schema={schema}/>);
|
|
63
57
|
})}
|
|
64
58
|
</div>);
|
|
65
59
|
}
|
|
@@ -19,8 +19,10 @@ export declare const de: {
|
|
|
19
19
|
body: string;
|
|
20
20
|
payload: string;
|
|
21
21
|
headers: string;
|
|
22
|
+
header: string;
|
|
22
23
|
authorizations: string;
|
|
23
24
|
responses: string;
|
|
25
|
+
response: string;
|
|
24
26
|
path_parameters: string;
|
|
25
27
|
query_parameters: string;
|
|
26
28
|
header_parameters: string;
|
|
@@ -33,5 +35,9 @@ export declare const de: {
|
|
|
33
35
|
show: string;
|
|
34
36
|
hide: string;
|
|
35
37
|
available_items: string;
|
|
36
|
-
|
|
38
|
+
available_scopes: string;
|
|
39
|
+
properties: string;
|
|
40
|
+
or: string;
|
|
41
|
+
and: string;
|
|
42
|
+
possible_values: string;
|
|
37
43
|
};
|
package/dist/translations/de.js
CHANGED
|
@@ -18,9 +18,11 @@ export var de = {
|
|
|
18
18
|
nullable: 'Nullfähig',
|
|
19
19
|
body: 'Rumpf',
|
|
20
20
|
payload: 'Nutzlast',
|
|
21
|
-
headers: '
|
|
21
|
+
headers: 'Header',
|
|
22
|
+
header: 'Header',
|
|
22
23
|
authorizations: 'Autorisierungen',
|
|
23
24
|
responses: 'Antworten',
|
|
25
|
+
response: 'Antwort',
|
|
24
26
|
path_parameters: 'Pfadparameter',
|
|
25
27
|
query_parameters: 'Abfrageparameter',
|
|
26
28
|
header_parameters: 'Header-Parameter',
|
|
@@ -30,8 +32,12 @@ export var de = {
|
|
|
30
32
|
success: 'Erfolg',
|
|
31
33
|
redirect: 'Umleitung',
|
|
32
34
|
error: 'Fehler',
|
|
33
|
-
show: '
|
|
34
|
-
hide: '
|
|
35
|
+
show: 'Zeige ${1}',
|
|
36
|
+
hide: 'Verstecke ${1}',
|
|
35
37
|
available_items: 'Verfügbare Elemente',
|
|
36
|
-
|
|
38
|
+
available_scopes: 'Verfügbare scopes',
|
|
39
|
+
properties: 'Eigenschaften',
|
|
40
|
+
or: 'oder',
|
|
41
|
+
and: 'und',
|
|
42
|
+
possible_values: 'Mögliche Werte',
|
|
37
43
|
};
|
|
@@ -19,8 +19,10 @@ export declare const en: {
|
|
|
19
19
|
body: string;
|
|
20
20
|
payload: string;
|
|
21
21
|
headers: string;
|
|
22
|
+
header: string;
|
|
22
23
|
authorizations: string;
|
|
23
24
|
responses: string;
|
|
25
|
+
response: string;
|
|
24
26
|
path_parameters: string;
|
|
25
27
|
query_parameters: string;
|
|
26
28
|
header_parameters: string;
|
|
@@ -33,5 +35,9 @@ export declare const en: {
|
|
|
33
35
|
show: string;
|
|
34
36
|
hide: string;
|
|
35
37
|
available_items: string;
|
|
36
|
-
|
|
38
|
+
available_scopes: string;
|
|
39
|
+
possible_values: string;
|
|
40
|
+
properties: string;
|
|
41
|
+
or: string;
|
|
42
|
+
and: string;
|
|
37
43
|
};
|
package/dist/translations/en.js
CHANGED
|
@@ -19,8 +19,10 @@ export var en = {
|
|
|
19
19
|
body: 'Body',
|
|
20
20
|
payload: 'Payload',
|
|
21
21
|
headers: 'Headers',
|
|
22
|
+
header: 'Header',
|
|
22
23
|
authorizations: 'Authorizations',
|
|
23
24
|
responses: 'Responses',
|
|
25
|
+
response: 'Response',
|
|
24
26
|
path_parameters: 'Path parameters',
|
|
25
27
|
query_parameters: 'Query parameters',
|
|
26
28
|
header_parameters: 'Header parameters',
|
|
@@ -30,8 +32,12 @@ export var en = {
|
|
|
30
32
|
success: 'Success',
|
|
31
33
|
redirect: 'Redirect',
|
|
32
34
|
error: 'Error',
|
|
33
|
-
show: 'Show',
|
|
34
|
-
hide: 'Hide',
|
|
35
|
+
show: 'Show ${1}',
|
|
36
|
+
hide: 'Hide ${1}',
|
|
35
37
|
available_items: 'Available items',
|
|
36
|
-
|
|
38
|
+
available_scopes: 'Available scopes',
|
|
39
|
+
possible_values: 'Possible values',
|
|
40
|
+
properties: 'Properties',
|
|
41
|
+
or: 'or',
|
|
42
|
+
and: 'and',
|
|
37
43
|
};
|
|
@@ -19,8 +19,10 @@ export declare const es: {
|
|
|
19
19
|
body: string;
|
|
20
20
|
payload: string;
|
|
21
21
|
headers: string;
|
|
22
|
+
header: string;
|
|
22
23
|
authorizations: string;
|
|
23
24
|
responses: string;
|
|
25
|
+
response: string;
|
|
24
26
|
path_parameters: string;
|
|
25
27
|
query_parameters: string;
|
|
26
28
|
header_parameters: string;
|
|
@@ -33,5 +35,9 @@ export declare const es: {
|
|
|
33
35
|
show: string;
|
|
34
36
|
hide: string;
|
|
35
37
|
available_items: string;
|
|
36
|
-
|
|
38
|
+
available_scopes: string;
|
|
39
|
+
properties: string;
|
|
40
|
+
or: string;
|
|
41
|
+
and: string;
|
|
42
|
+
possible_values: string;
|
|
37
43
|
};
|
package/dist/translations/es.js
CHANGED
|
@@ -18,9 +18,11 @@ export var es = {
|
|
|
18
18
|
nullable: 'Nulo',
|
|
19
19
|
body: 'Cuerpo',
|
|
20
20
|
payload: 'Caga útil',
|
|
21
|
-
headers: '
|
|
21
|
+
headers: 'Headers',
|
|
22
|
+
header: 'Header',
|
|
22
23
|
authorizations: 'Autorizaciones',
|
|
23
24
|
responses: 'Respuestas',
|
|
25
|
+
response: 'Respuesta',
|
|
24
26
|
path_parameters: 'Parámetros de ruta',
|
|
25
27
|
query_parameters: 'Parámetros de consulta',
|
|
26
28
|
header_parameters: 'Parámetros de encabezado',
|
|
@@ -30,8 +32,12 @@ export var es = {
|
|
|
30
32
|
success: 'Éxito',
|
|
31
33
|
redirect: 'Redirección',
|
|
32
34
|
error: 'Error',
|
|
33
|
-
show: 'Mostrar',
|
|
34
|
-
hide: 'Ocultar',
|
|
35
|
+
show: 'Mostrar ${1}',
|
|
36
|
+
hide: 'Ocultar ${1}',
|
|
35
37
|
available_items: 'Elementos disponibles',
|
|
36
|
-
|
|
38
|
+
available_scopes: 'Scopes disponibles',
|
|
39
|
+
properties: 'Propiedades',
|
|
40
|
+
or: 'o',
|
|
41
|
+
and: 'y',
|
|
42
|
+
possible_values: 'Valores posibles',
|
|
37
43
|
};
|
|
@@ -19,8 +19,10 @@ export declare const fr: {
|
|
|
19
19
|
body: string;
|
|
20
20
|
payload: string;
|
|
21
21
|
headers: string;
|
|
22
|
+
header: string;
|
|
22
23
|
authorizations: string;
|
|
23
24
|
responses: string;
|
|
25
|
+
response: string;
|
|
24
26
|
path_parameters: string;
|
|
25
27
|
query_parameters: string;
|
|
26
28
|
header_parameters: string;
|
|
@@ -33,5 +35,9 @@ export declare const fr: {
|
|
|
33
35
|
show: string;
|
|
34
36
|
hide: string;
|
|
35
37
|
available_items: string;
|
|
36
|
-
|
|
38
|
+
available_scopes: string;
|
|
39
|
+
properties: string;
|
|
40
|
+
or: string;
|
|
41
|
+
and: string;
|
|
42
|
+
possible_values: string;
|
|
37
43
|
};
|
package/dist/translations/fr.js
CHANGED
|
@@ -18,20 +18,26 @@ export var fr = {
|
|
|
18
18
|
nullable: 'Nullable',
|
|
19
19
|
body: 'Corps',
|
|
20
20
|
payload: 'Charge utile',
|
|
21
|
-
headers: '
|
|
21
|
+
headers: 'Headers',
|
|
22
|
+
header: 'Header',
|
|
22
23
|
authorizations: 'Autorisations',
|
|
23
24
|
responses: 'Réponses',
|
|
25
|
+
response: 'Réponse',
|
|
24
26
|
path_parameters: 'Paramètres de chemin',
|
|
25
27
|
query_parameters: 'Paramètres de requête',
|
|
26
|
-
header_parameters:
|
|
28
|
+
header_parameters: "Paramètres d'en-tête",
|
|
27
29
|
attributes: 'Attributs',
|
|
28
30
|
test_it: 'Tester',
|
|
29
31
|
information: 'Information',
|
|
30
32
|
success: 'Succès',
|
|
31
33
|
redirect: 'Redirection',
|
|
32
34
|
error: 'Erreur',
|
|
33
|
-
show: 'Afficher',
|
|
34
|
-
hide: 'Masquer',
|
|
35
|
+
show: 'Afficher ${1}',
|
|
36
|
+
hide: 'Masquer ${1}',
|
|
35
37
|
available_items: 'Éléments disponibles',
|
|
36
|
-
|
|
38
|
+
available_scopes: 'Scopes disponibles',
|
|
39
|
+
properties: 'Propriétés',
|
|
40
|
+
or: 'ou',
|
|
41
|
+
and: 'et',
|
|
42
|
+
possible_values: 'Valeurs possibles',
|
|
37
43
|
};
|