@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
package/src/code-samples.ts
CHANGED
|
@@ -30,7 +30,7 @@ export const codeSampleGenerators: CodeSampleGenerator[] = [
|
|
|
30
30
|
{
|
|
31
31
|
id: 'http',
|
|
32
32
|
label: 'HTTP',
|
|
33
|
-
syntax: '
|
|
33
|
+
syntax: 'http',
|
|
34
34
|
generate: ({ method, url, headers = {}, body }: CodeSampleInput) => {
|
|
35
35
|
const { host, path } = parseHostAndPath(url);
|
|
36
36
|
|
|
@@ -356,18 +356,25 @@ const BodyGenerators = {
|
|
|
356
356
|
// Convert JSON to XML if needed
|
|
357
357
|
body = JSON.stringify(convertBodyToXML(body));
|
|
358
358
|
} else {
|
|
359
|
-
body = stringifyOpenAPI(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
359
|
+
body = stringifyOpenAPI(
|
|
360
|
+
body,
|
|
361
|
+
(_key, value) => {
|
|
362
|
+
switch (value) {
|
|
363
|
+
case true:
|
|
364
|
+
return '$$__TRUE__$$';
|
|
365
|
+
case false:
|
|
366
|
+
return '$$__FALSE__$$';
|
|
367
|
+
case null:
|
|
368
|
+
return '$$__NULL__$$';
|
|
369
|
+
default:
|
|
370
|
+
return value;
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
2
|
|
374
|
+
)
|
|
369
375
|
.replaceAll('"$$__TRUE__$$"', 'True')
|
|
370
|
-
.replaceAll('"$$__FALSE__$$"', 'False')
|
|
376
|
+
.replaceAll('"$$__FALSE__$$"', 'False')
|
|
377
|
+
.replaceAll('"$$__NULL__$$"', 'None');
|
|
371
378
|
}
|
|
372
379
|
|
|
373
380
|
return { body, code, headers };
|
|
@@ -1017,4 +1017,24 @@ describe('generateSchemaExample', () => {
|
|
|
1017
1017
|
},
|
|
1018
1018
|
});
|
|
1019
1019
|
});
|
|
1020
|
+
|
|
1021
|
+
it('handles deprecated properties', () => {
|
|
1022
|
+
expect(
|
|
1023
|
+
generateSchemaExample({
|
|
1024
|
+
type: 'object',
|
|
1025
|
+
deprecated: true,
|
|
1026
|
+
})
|
|
1027
|
+
).toBeUndefined();
|
|
1028
|
+
});
|
|
1029
|
+
|
|
1030
|
+
it('handle nested deprecated properties', () => {
|
|
1031
|
+
expect(
|
|
1032
|
+
generateSchemaExample({
|
|
1033
|
+
type: 'array',
|
|
1034
|
+
items: {
|
|
1035
|
+
deprecated: true,
|
|
1036
|
+
},
|
|
1037
|
+
})
|
|
1038
|
+
).toBeUndefined();
|
|
1039
|
+
});
|
|
1020
1040
|
});
|
|
@@ -167,7 +167,7 @@ const getExampleFromSchema = (
|
|
|
167
167
|
const makeUpRandomData = !!options?.emptyString;
|
|
168
168
|
|
|
169
169
|
// If the property is deprecated we don't show it in examples.
|
|
170
|
-
if (schema.deprecated) {
|
|
170
|
+
if (schema.deprecated || (schema.type === 'array' && schema.items?.deprecated)) {
|
|
171
171
|
return undefined;
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -204,6 +204,14 @@ const getExampleFromSchema = (
|
|
|
204
204
|
return cache(schema, schema.example);
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
+
// Use a default value, if there’s one and it’s a string or number
|
|
208
|
+
if (
|
|
209
|
+
schema.default !== undefined &&
|
|
210
|
+
['string', 'number', 'boolean'].includes(typeof schema.default)
|
|
211
|
+
) {
|
|
212
|
+
return cache(schema, schema.default);
|
|
213
|
+
}
|
|
214
|
+
|
|
207
215
|
// enum: [ 'available', 'pending', 'sold' ]
|
|
208
216
|
if (Array.isArray(schema.enum) && schema.enum.length > 0) {
|
|
209
217
|
return cache(schema, schema.enum[0]);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
4
|
+
import type { OpenAPIClientContext } from './context';
|
|
5
|
+
import { tString } from './translate';
|
|
6
|
+
|
|
7
|
+
export function getDisclosureLabel(props: {
|
|
8
|
+
schema: OpenAPIV3.SchemaObject;
|
|
9
|
+
isExpanded: boolean;
|
|
10
|
+
context: OpenAPIClientContext;
|
|
11
|
+
}) {
|
|
12
|
+
const { schema, isExpanded, context } = props;
|
|
13
|
+
let label: string;
|
|
14
|
+
if (schema.type === 'array' && !!schema.items) {
|
|
15
|
+
if (schema.items.oneOf) {
|
|
16
|
+
label = tString(context.translation, 'available_items').toLowerCase();
|
|
17
|
+
} else {
|
|
18
|
+
label = tString(context.translation, 'properties').toLowerCase();
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
label = tString(context.translation, 'properties').toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return tString(context.translation, isExpanded ? 'hide' : 'show', label);
|
|
25
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { SectionBody } from '../StaticSection';
|
|
4
|
+
|
|
5
|
+
import type { OpenAPIV3 } from '@gitbook/openapi-parser';
|
|
6
|
+
import { OpenAPIDisclosure } from '../OpenAPIDisclosure';
|
|
7
|
+
import { OpenAPIRootSchema } from '../OpenAPISchemaServer';
|
|
8
|
+
import { Section } from '../StaticSection';
|
|
9
|
+
import type { OpenAPIClientContext } from '../context';
|
|
10
|
+
import { getDisclosureLabel } from '../getDisclosureLabel';
|
|
11
|
+
|
|
12
|
+
export function OpenAPISchemaItem(props: {
|
|
13
|
+
name: string;
|
|
14
|
+
schema: OpenAPIV3.SchemaObject;
|
|
15
|
+
context: OpenAPIClientContext;
|
|
16
|
+
}) {
|
|
17
|
+
const { schema, context, name } = props;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<OpenAPIDisclosure
|
|
21
|
+
className="openapi-schemas-disclosure"
|
|
22
|
+
key={name}
|
|
23
|
+
icon={context.icons.plus}
|
|
24
|
+
header={name}
|
|
25
|
+
label={(isExpanded) => getDisclosureLabel({ schema, isExpanded, context })}
|
|
26
|
+
>
|
|
27
|
+
<Section className="openapi-section-schemas">
|
|
28
|
+
<SectionBody>
|
|
29
|
+
<OpenAPIRootSchema schema={schema} context={context} />
|
|
30
|
+
</SectionBody>
|
|
31
|
+
</Section>
|
|
32
|
+
</OpenAPIDisclosure>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { OpenAPISchema } from '@gitbook/openapi-parser';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { OpenAPIDisclosure } from '../OpenAPIDisclosure';
|
|
4
3
|
import { OpenAPIExample } from '../OpenAPIExample';
|
|
5
4
|
import { OpenAPIRootSchema } from '../OpenAPISchemaServer';
|
|
6
|
-
import {
|
|
5
|
+
import { StaticSection } from '../StaticSection';
|
|
7
6
|
import {
|
|
8
7
|
type OpenAPIContextInput,
|
|
9
8
|
getOpenAPIClientContext,
|
|
@@ -11,6 +10,7 @@ import {
|
|
|
11
10
|
} from '../context';
|
|
12
11
|
import { t } from '../translate';
|
|
13
12
|
import { getExampleFromSchema } from '../util/example';
|
|
13
|
+
import { OpenAPISchemaItem } from './OpenAPISchemaItem';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* OpenAPI Schemas component.
|
|
@@ -85,18 +85,12 @@ export function OpenAPISchemas(props: {
|
|
|
85
85
|
<div className={clsx('openapi-schemas', className)}>
|
|
86
86
|
{schemas.map(({ name, schema }) => {
|
|
87
87
|
return (
|
|
88
|
-
<
|
|
89
|
-
className="openapi-schemas-disclosure"
|
|
88
|
+
<OpenAPISchemaItem
|
|
90
89
|
key={name}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<SectionBody>
|
|
96
|
-
<OpenAPIRootSchema schema={schema} context={clientContext} />
|
|
97
|
-
</SectionBody>
|
|
98
|
-
</Section>
|
|
99
|
-
</OpenAPIDisclosure>
|
|
90
|
+
name={name}
|
|
91
|
+
context={clientContext}
|
|
92
|
+
schema={schema}
|
|
93
|
+
/>
|
|
100
94
|
);
|
|
101
95
|
})}
|
|
102
96
|
</div>
|
package/src/translations/de.ts
CHANGED
|
@@ -18,9 +18,11 @@ export const 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 const 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
|
};
|
package/src/translations/en.ts
CHANGED
|
@@ -19,8 +19,10 @@ export const 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 const 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
|
};
|
package/src/translations/es.ts
CHANGED
|
@@ -18,9 +18,11 @@ export const 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 const 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
|
};
|
package/src/translations/fr.ts
CHANGED
|
@@ -18,20 +18,26 @@ export const 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
|
};
|
package/src/translations/ja.ts
CHANGED
|
@@ -19,8 +19,10 @@ export const ja = {
|
|
|
19
19
|
body: '本文',
|
|
20
20
|
payload: 'ペイロード',
|
|
21
21
|
headers: 'ヘッダー',
|
|
22
|
+
header: 'ヘッダー',
|
|
22
23
|
authorizations: '認可',
|
|
23
24
|
responses: 'レスポンス',
|
|
25
|
+
response: 'レスポンス',
|
|
24
26
|
path_parameters: 'パスパラメータ',
|
|
25
27
|
query_parameters: 'クエリパラメータ',
|
|
26
28
|
header_parameters: 'ヘッダーパラメータ',
|
|
@@ -30,8 +32,12 @@ export const ja = {
|
|
|
30
32
|
success: '成功',
|
|
31
33
|
redirect: 'リダイレクト',
|
|
32
34
|
error: 'エラー',
|
|
33
|
-
show: '
|
|
34
|
-
hide: '
|
|
35
|
+
show: '${1}を表示',
|
|
36
|
+
hide: '${1}を非表示',
|
|
35
37
|
available_items: '利用可能なアイテム',
|
|
36
|
-
|
|
38
|
+
available_scopes: '利用可能なスコープ',
|
|
39
|
+
properties: 'プロパティ',
|
|
40
|
+
or: 'または',
|
|
41
|
+
and: 'かつ',
|
|
42
|
+
possible_values: '可能な値',
|
|
37
43
|
};
|
package/src/translations/nl.ts
CHANGED
|
@@ -19,8 +19,10 @@ export const nl = {
|
|
|
19
19
|
body: 'Body',
|
|
20
20
|
payload: 'Payload',
|
|
21
21
|
headers: 'Headers',
|
|
22
|
+
header: 'Header',
|
|
22
23
|
authorizations: 'Autorisaties',
|
|
23
24
|
responses: 'Reacties',
|
|
25
|
+
response: 'Reactie',
|
|
24
26
|
path_parameters: 'Padparameters',
|
|
25
27
|
query_parameters: 'Queryparameters',
|
|
26
28
|
header_parameters: 'Headerparameters',
|
|
@@ -30,8 +32,12 @@ export const nl = {
|
|
|
30
32
|
success: 'Succes',
|
|
31
33
|
redirect: 'Omleiding',
|
|
32
34
|
error: 'Fout',
|
|
33
|
-
show: 'Toon',
|
|
34
|
-
hide: '
|
|
35
|
+
show: 'Toon ${1}',
|
|
36
|
+
hide: 'Verberg ${1}',
|
|
35
37
|
available_items: 'Beschikbare items',
|
|
36
|
-
|
|
38
|
+
available_scopes: 'Beschikbare scopes',
|
|
39
|
+
properties: 'Eigenschappen',
|
|
40
|
+
or: 'of',
|
|
41
|
+
and: 'en',
|
|
42
|
+
possible_values: 'Mogelijke waarden',
|
|
37
43
|
};
|
package/src/translations/no.ts
CHANGED
|
@@ -18,9 +18,11 @@ export const no = {
|
|
|
18
18
|
nullable: 'Kan være null',
|
|
19
19
|
body: 'Brødtekst',
|
|
20
20
|
payload: 'Nyttelast',
|
|
21
|
-
headers: '
|
|
21
|
+
headers: 'Headers',
|
|
22
|
+
header: 'Header',
|
|
22
23
|
authorizations: 'Autorisasjoner',
|
|
23
24
|
responses: 'Responser',
|
|
25
|
+
response: 'Respons',
|
|
24
26
|
path_parameters: 'Sti-parametere',
|
|
25
27
|
query_parameters: 'Forespørselsparametere',
|
|
26
28
|
header_parameters: 'Header-parametere',
|
|
@@ -30,8 +32,12 @@ export const no = {
|
|
|
30
32
|
success: 'Suksess',
|
|
31
33
|
redirect: 'Viderekobling',
|
|
32
34
|
error: 'Feil',
|
|
33
|
-
show: 'Vis',
|
|
34
|
-
hide: 'Skjul',
|
|
35
|
+
show: 'Vis ${1}',
|
|
36
|
+
hide: 'Skjul ${1}',
|
|
35
37
|
available_items: 'Tilgjengelige elementer',
|
|
36
|
-
|
|
38
|
+
available_scopes: 'Tilgjengelige scopes',
|
|
39
|
+
properties: 'Egenskaper',
|
|
40
|
+
or: 'eller',
|
|
41
|
+
and: 'og',
|
|
42
|
+
possible_values: 'Mulige verdier',
|
|
37
43
|
};
|
|
@@ -18,9 +18,11 @@ export const pt_br = {
|
|
|
18
18
|
nullable: 'Nulo',
|
|
19
19
|
body: 'Corpo',
|
|
20
20
|
payload: 'Carga útil',
|
|
21
|
-
headers: '
|
|
21
|
+
headers: 'Headers',
|
|
22
|
+
header: 'Header',
|
|
22
23
|
authorizations: 'Autorizações',
|
|
23
24
|
responses: 'Respostas',
|
|
25
|
+
response: 'Resposta',
|
|
24
26
|
path_parameters: 'Parâmetros de rota',
|
|
25
27
|
query_parameters: 'Parâmetros de consulta',
|
|
26
28
|
header_parameters: 'Parâmetros de cabeçalho',
|
|
@@ -30,8 +32,12 @@ export const pt_br = {
|
|
|
30
32
|
success: 'Sucesso',
|
|
31
33
|
redirect: 'Redirecionamento',
|
|
32
34
|
error: 'Erro',
|
|
33
|
-
show: 'Mostrar',
|
|
34
|
-
hide: 'Ocultar',
|
|
35
|
+
show: 'Mostrar ${1}',
|
|
36
|
+
hide: 'Ocultar ${1}',
|
|
35
37
|
available_items: 'Itens disponíveis',
|
|
36
|
-
|
|
38
|
+
available_scopes: 'Scopes disponíveis',
|
|
39
|
+
properties: 'Propriedades',
|
|
40
|
+
or: 'ou',
|
|
41
|
+
and: 'e',
|
|
42
|
+
possible_values: 'Valores possíveis',
|
|
37
43
|
};
|
package/src/translations/zh.ts
CHANGED
|
@@ -18,9 +18,11 @@ export const zh = {
|
|
|
18
18
|
nullable: '可为 null',
|
|
19
19
|
body: '请求体',
|
|
20
20
|
payload: '有效载荷',
|
|
21
|
-
headers: '
|
|
21
|
+
headers: '头字段',
|
|
22
|
+
header: '头部',
|
|
22
23
|
authorizations: '授权',
|
|
23
24
|
responses: '响应',
|
|
25
|
+
response: '响应',
|
|
24
26
|
path_parameters: '路径参数',
|
|
25
27
|
query_parameters: '查询参数',
|
|
26
28
|
header_parameters: '头参数',
|
|
@@ -30,8 +32,12 @@ export const zh = {
|
|
|
30
32
|
success: '成功',
|
|
31
33
|
redirect: '重定向',
|
|
32
34
|
error: '错误',
|
|
33
|
-
show: '
|
|
34
|
-
hide: '
|
|
35
|
+
show: '显示${1}',
|
|
36
|
+
hide: '隐藏${1}',
|
|
35
37
|
available_items: '可用项',
|
|
36
|
-
|
|
38
|
+
available_scopes: '可用范围',
|
|
39
|
+
properties: '属性',
|
|
40
|
+
or: '或',
|
|
41
|
+
and: '和',
|
|
42
|
+
possible_values: '可能的值',
|
|
37
43
|
};
|
package/src/utils.ts
CHANGED
|
@@ -216,3 +216,40 @@ function getStatusCodeCategory(statusCode: number | string): number | string {
|
|
|
216
216
|
|
|
217
217
|
return category;
|
|
218
218
|
}
|
|
219
|
+
|
|
220
|
+
export function getSchemaTitle(schema: OpenAPIV3.SchemaObject): string {
|
|
221
|
+
// Otherwise try to infer a nice title
|
|
222
|
+
let type = 'any';
|
|
223
|
+
|
|
224
|
+
if (schema.enum || schema['x-enumDescriptions'] || schema['x-gitbook-enum']) {
|
|
225
|
+
type = `${schema.type} · enum`;
|
|
226
|
+
// check array AND schema.items as this is sometimes null despite what the type indicates
|
|
227
|
+
} else if (schema.type === 'array' && !!schema.items) {
|
|
228
|
+
type = `${getSchemaTitle(schema.items)}[]`;
|
|
229
|
+
} else if (Array.isArray(schema.type)) {
|
|
230
|
+
type = schema.type.join(' | ');
|
|
231
|
+
} else if (schema.type || schema.properties) {
|
|
232
|
+
type = schema.type ?? 'object';
|
|
233
|
+
|
|
234
|
+
if (schema.format) {
|
|
235
|
+
type += ` · ${schema.format}`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Only add the title if it's an object (no need for the title of a string, number, etc.)
|
|
239
|
+
if (type === 'object' && schema.title) {
|
|
240
|
+
type += ` · ${schema.title.replaceAll(' ', '')}`;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if ('anyOf' in schema) {
|
|
245
|
+
type = 'any of';
|
|
246
|
+
} else if ('oneOf' in schema) {
|
|
247
|
+
type = 'one of';
|
|
248
|
+
} else if ('allOf' in schema) {
|
|
249
|
+
type = 'all of';
|
|
250
|
+
} else if ('not' in schema) {
|
|
251
|
+
type = 'not';
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return type;
|
|
255
|
+
}
|