@gitbook/react-openapi 1.5.1 → 1.5.3
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 +27 -0
- package/dist/InteractiveSection.js +59 -0
- package/dist/Markdown.js +10 -0
- package/dist/OpenAPICodeSample.js +219 -0
- package/dist/OpenAPICodeSampleInteractive.js +62 -0
- package/dist/OpenAPICodeSampleSelector.js +45 -0
- package/dist/OpenAPICopyButton.js +44 -0
- package/dist/OpenAPIDisclosure.js +28 -0
- package/dist/OpenAPIDisclosureGroup.js +89 -0
- package/dist/OpenAPIExample.js +41 -0
- package/dist/OpenAPIMediaType.js +58 -0
- package/dist/OpenAPIOperation.d.ts +15 -0
- package/dist/OpenAPIOperation.js +30 -0
- package/dist/OpenAPIOperationContext.d.ts +20 -0
- package/dist/OpenAPIOperationContext.js +30 -0
- package/dist/OpenAPIPath.js +25 -0
- package/dist/OpenAPIPathItem.js +22 -0
- package/dist/OpenAPIPathMultipleServers.js +43 -0
- package/dist/OpenAPIPrefillContextProvider.d.ts +26 -0
- package/dist/OpenAPIPrefillContextProvider.js +25 -0
- package/dist/OpenAPIRequestBody.js +28 -0
- package/dist/OpenAPIRequestBodyHeaderType.js +23 -0
- package/dist/OpenAPIRequiredScopes.js +67 -0
- package/dist/OpenAPIResponse.js +39 -0
- package/dist/OpenAPIResponseExample.js +75 -0
- package/dist/OpenAPIResponseExampleContent.js +61 -0
- package/dist/OpenAPIResponses.js +61 -0
- package/dist/OpenAPISchema.js +373 -0
- package/dist/OpenAPISchemaName.js +45 -0
- package/dist/OpenAPISchemaServer.js +13 -0
- package/dist/OpenAPISecurities.js +98 -0
- package/dist/OpenAPISelect.js +45 -0
- package/dist/OpenAPISpec.js +73 -0
- package/dist/OpenAPITooltip.js +23 -0
- package/dist/OpenAPIWebhook.d.ts +15 -0
- package/dist/OpenAPIWebhook.js +28 -0
- package/dist/OpenAPIWebhookExample.js +40 -0
- package/dist/ScalarApiButton.js +90 -0
- package/dist/StaticSection.js +37 -0
- package/dist/code-samples.js +305 -0
- package/dist/common/OpenAPIColumnSpec.js +23 -0
- package/dist/common/OpenAPIOperationDescription.js +18 -0
- package/dist/common/OpenAPIStability.js +17 -0
- package/dist/common/OpenAPISummary.js +27 -0
- package/dist/contentTypeChecks.js +34 -0
- package/dist/context.d.ts +74 -0
- package/dist/context.js +29 -0
- package/dist/decycle.js +41 -0
- package/dist/dereference.js +24 -0
- package/dist/formatPath.js +25 -0
- package/dist/generateSchemaExample.js +198 -0
- package/dist/getDisclosureLabel.js +17 -0
- package/dist/getOrCreateDisclosureStoreByKey.js +31 -0
- package/dist/getOrCreateStoreByKey.js +22 -0
- package/dist/index.d.ts +11 -662
- package/dist/index.js +9 -3871
- package/dist/json2xml.js +12 -0
- package/dist/resolveOpenAPIOperation.d.ts +15 -0
- package/dist/resolveOpenAPIOperation.js +105 -0
- package/dist/resolveOpenAPIWebhook.d.ts +15 -0
- package/dist/resolveOpenAPIWebhook.js +52 -0
- package/dist/schemas/OpenAPISchemaItem.js +26 -0
- package/dist/schemas/OpenAPISchemas.d.ts +19 -0
- package/dist/schemas/OpenAPISchemas.js +57 -0
- package/dist/schemas/resolveOpenAPISchemas.d.ts +15 -0
- package/dist/schemas/resolveOpenAPISchemas.js +17 -0
- package/dist/stringifyOpenAPI.js +14 -0
- package/dist/translate.js +43 -0
- package/dist/translations/de.js +50 -0
- package/dist/translations/en.d.ts +49 -0
- package/dist/translations/en.js +50 -0
- package/dist/translations/es.js +50 -0
- package/dist/translations/fr.js +50 -0
- package/dist/translations/index.d.ts +426 -0
- package/dist/translations/index.js +31 -0
- package/dist/translations/ja.js +50 -0
- package/dist/translations/nl.js +50 -0
- package/dist/translations/no.js +50 -0
- package/dist/translations/pt-br.js +50 -0
- package/dist/translations/types.d.ts +7 -0
- package/dist/translations/zh.js +50 -0
- package/dist/types.d.ts +38 -0
- package/dist/util/example.js +84 -0
- package/dist/util/server.js +38 -0
- package/dist/util/tryit-prefill.js +143 -0
- package/dist/utils.js +163 -0
- package/package.json +28 -12
package/dist/json2xml.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OpenAPIOperationData } from "./types.js";
|
|
2
|
+
import { Filesystem, OpenAPIV3xDocument } from "@gitbook/openapi-parser";
|
|
3
|
+
import "flatted";
|
|
4
|
+
|
|
5
|
+
//#region src/resolveOpenAPIOperation.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Resolve an OpenAPI operation in a file and compile it to a more usable format.
|
|
9
|
+
*/
|
|
10
|
+
declare function resolveOpenAPIOperation(filesystem: Filesystem<OpenAPIV3xDocument>, operationDescriptor: {
|
|
11
|
+
path: string;
|
|
12
|
+
method: string;
|
|
13
|
+
}): Promise<OpenAPIOperationData | null>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { resolveOpenAPIOperation };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { checkIsReference } from "./utils.js";
|
|
2
|
+
import { dereferenceFilesystem } from "./dereference.js";
|
|
3
|
+
import "flatted";
|
|
4
|
+
|
|
5
|
+
//#region src/resolveOpenAPIOperation.ts
|
|
6
|
+
/**
|
|
7
|
+
* Resolve an OpenAPI operation in a file and compile it to a more usable format.
|
|
8
|
+
*/
|
|
9
|
+
async function resolveOpenAPIOperation(filesystem, operationDescriptor) {
|
|
10
|
+
const { path, method } = operationDescriptor;
|
|
11
|
+
const schema = await dereferenceFilesystem(filesystem);
|
|
12
|
+
let operation = getOperationByPathAndMethod(schema, path, method);
|
|
13
|
+
if (!operation) return null;
|
|
14
|
+
const commonParameters = getPathObjectParameter(schema, path);
|
|
15
|
+
if (commonParameters) operation = {
|
|
16
|
+
...operation,
|
|
17
|
+
parameters: [...commonParameters, ...operation.parameters ?? []]
|
|
18
|
+
};
|
|
19
|
+
const servers = "servers" in schema ? schema.servers ?? [] : [];
|
|
20
|
+
const schemaSecurity = Array.isArray(schema.security) ? schema.security : schema.security ? [schema.security] : [];
|
|
21
|
+
const security = operation.security ?? schemaSecurity;
|
|
22
|
+
const isOptionalSecurity = security.some((entry) => Object.keys(entry).length === 0);
|
|
23
|
+
const flatSecurities = flattenSecurities(security);
|
|
24
|
+
const securities = [];
|
|
25
|
+
for (const entry of flatSecurities) {
|
|
26
|
+
const [securityKey, operationScopes] = Object.entries(entry)[0] ?? [];
|
|
27
|
+
if (securityKey) {
|
|
28
|
+
const securityScheme = schema.components?.securitySchemes?.[securityKey];
|
|
29
|
+
const scopes = resolveSecurityScopes({
|
|
30
|
+
securityScheme,
|
|
31
|
+
operationScopes
|
|
32
|
+
});
|
|
33
|
+
securities.push([securityKey, {
|
|
34
|
+
...securityScheme,
|
|
35
|
+
required: !isOptionalSecurity,
|
|
36
|
+
scopes
|
|
37
|
+
}]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
servers,
|
|
42
|
+
operation: {
|
|
43
|
+
...operation,
|
|
44
|
+
security
|
|
45
|
+
},
|
|
46
|
+
method,
|
|
47
|
+
path,
|
|
48
|
+
securities,
|
|
49
|
+
"x-codeSamples": typeof schema["x-codeSamples"] === "boolean" ? schema["x-codeSamples"] : void 0,
|
|
50
|
+
"x-hideTryItPanel": typeof schema["x-hideTryItPanel"] === "boolean" ? schema["x-hideTryItPanel"] : void 0
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get a path object from its path.
|
|
55
|
+
*/
|
|
56
|
+
function getPathObject(schema, path) {
|
|
57
|
+
return schema.paths?.[path] || null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolve parameters from a path in an OpenAPI schema.
|
|
61
|
+
*/
|
|
62
|
+
function getPathObjectParameter(schema, path) {
|
|
63
|
+
const pathObject = getPathObject(schema, path);
|
|
64
|
+
if (pathObject?.parameters) return pathObject.parameters;
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get an operation by its path and method.
|
|
69
|
+
*/
|
|
70
|
+
function getOperationByPathAndMethod(schema, path, method) {
|
|
71
|
+
const pathObject = getPathObject(schema, path);
|
|
72
|
+
if (!pathObject) return null;
|
|
73
|
+
const normalizedMethod = method.toLowerCase();
|
|
74
|
+
if (!pathObject[normalizedMethod]) return null;
|
|
75
|
+
return pathObject[normalizedMethod];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Flatten security objects in case they are nested.
|
|
79
|
+
* @example [{bearerAuth:[], basicAuth:[]}] => [{ bearerAuth: [] }, { basicAuth: [] }]
|
|
80
|
+
*/
|
|
81
|
+
function flattenSecurities(security) {
|
|
82
|
+
if (!Array.isArray(security) || security.length === 0) return [];
|
|
83
|
+
return security.flatMap((securityObject) => {
|
|
84
|
+
return Object.entries(securityObject).map(([authType, config]) => ({ [authType]: config }));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Resolve the scopes for a security scheme.
|
|
89
|
+
*/
|
|
90
|
+
function resolveSecurityScopes({ securityScheme, operationScopes }) {
|
|
91
|
+
if (!operationScopes?.length || !securityScheme || checkIsReference(securityScheme)) return null;
|
|
92
|
+
if (isOAuthSecurityScheme(securityScheme)) return (securityScheme.flows ? Object.entries(securityScheme.flows) : []).flatMap(([_, flow]) => {
|
|
93
|
+
return Object.entries(flow.scopes ?? {}).filter(([scope]) => operationScopes.includes(scope));
|
|
94
|
+
});
|
|
95
|
+
return operationScopes.map((scope) => [scope, void 0]);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Check if a security scheme is an OAuth or OpenID Connect security scheme.
|
|
99
|
+
*/
|
|
100
|
+
function isOAuthSecurityScheme(securityScheme) {
|
|
101
|
+
return securityScheme.type === "oauth2";
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
export { resolveOpenAPIOperation };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OpenAPIWebhookData } from "./types.js";
|
|
2
|
+
import { Filesystem, OpenAPIV3xDocument } from "@gitbook/openapi-parser";
|
|
3
|
+
import "flatted";
|
|
4
|
+
|
|
5
|
+
//#region src/resolveOpenAPIWebhook.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Resolve an OpenAPI webhook in a file and compile it to a more usable format.
|
|
9
|
+
*/
|
|
10
|
+
declare function resolveOpenAPIWebhook(filesystem: Filesystem<OpenAPIV3xDocument>, webhookDescriptor: {
|
|
11
|
+
name: string;
|
|
12
|
+
method: string;
|
|
13
|
+
}): Promise<OpenAPIWebhookData | null>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { resolveOpenAPIWebhook };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { dereferenceFilesystem } from "./dereference.js";
|
|
2
|
+
import "flatted";
|
|
3
|
+
|
|
4
|
+
//#region src/resolveOpenAPIWebhook.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolve an OpenAPI webhook in a file and compile it to a more usable format.
|
|
7
|
+
*/
|
|
8
|
+
async function resolveOpenAPIWebhook(filesystem, webhookDescriptor) {
|
|
9
|
+
const { name, method } = webhookDescriptor;
|
|
10
|
+
const schema = await dereferenceFilesystem(filesystem);
|
|
11
|
+
let operation = getWebhookByNameAndMethod(schema, name, method);
|
|
12
|
+
if (!operation) return null;
|
|
13
|
+
const commonParameters = getPathObjectParameter(schema, name);
|
|
14
|
+
if (commonParameters) operation = {
|
|
15
|
+
...operation,
|
|
16
|
+
parameters: [...commonParameters, ...operation.parameters ?? []]
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
servers: "servers" in schema ? schema.servers ?? [] : [],
|
|
20
|
+
operation,
|
|
21
|
+
method,
|
|
22
|
+
name
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get a path object from its path.
|
|
27
|
+
*/
|
|
28
|
+
function getPathObject(schema, name) {
|
|
29
|
+
if (schema.webhooks?.[name]) return schema.webhooks[name];
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve parameters from a path in an OpenAPI schema.
|
|
34
|
+
*/
|
|
35
|
+
function getPathObjectParameter(schema, path) {
|
|
36
|
+
const pathObject = getPathObject(schema, path);
|
|
37
|
+
if (pathObject?.parameters) return pathObject.parameters;
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get an operation by its path and method.
|
|
42
|
+
*/
|
|
43
|
+
function getWebhookByNameAndMethod(schema, name, method) {
|
|
44
|
+
const pathObject = getPathObject(schema, name);
|
|
45
|
+
if (!pathObject) return null;
|
|
46
|
+
const normalizedMethod = method.toLowerCase();
|
|
47
|
+
if (!pathObject[normalizedMethod]) return null;
|
|
48
|
+
return pathObject[normalizedMethod];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { resolveOpenAPIWebhook };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { OpenAPIDisclosure } from "../OpenAPIDisclosure.js";
|
|
5
|
+
import { getDisclosureLabel } from "../getDisclosureLabel.js";
|
|
6
|
+
import { OpenAPIRootSchema } from "../OpenAPISchemaServer.js";
|
|
7
|
+
import { Section, SectionBody } from "../StaticSection.js";
|
|
8
|
+
|
|
9
|
+
//#region src/schemas/OpenAPISchemaItem.tsx
|
|
10
|
+
function OpenAPISchemaItem(props) {
|
|
11
|
+
const { schema, context, name } = props;
|
|
12
|
+
return <OpenAPIDisclosure className="openapi-schemas-disclosure" key={name} icon={context.icons.plus} header={name} label={(isExpanded) => getDisclosureLabel({
|
|
13
|
+
schema,
|
|
14
|
+
isExpanded,
|
|
15
|
+
context
|
|
16
|
+
})}>
|
|
17
|
+
<Section className="openapi-section-schemas">
|
|
18
|
+
<SectionBody>
|
|
19
|
+
<OpenAPIRootSchema schema={schema} context={context} />
|
|
20
|
+
</SectionBody>
|
|
21
|
+
</Section>
|
|
22
|
+
</OpenAPIDisclosure>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { OpenAPISchemaItem };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OpenAPIContextInput } from "../context.js";
|
|
2
|
+
import * as react2 from "react";
|
|
3
|
+
import { OpenAPISchema } from "@gitbook/openapi-parser";
|
|
4
|
+
|
|
5
|
+
//#region src/schemas/OpenAPISchemas.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* OpenAPI Schemas component.
|
|
8
|
+
*/
|
|
9
|
+
declare function OpenAPISchemas(props: {
|
|
10
|
+
className?: string;
|
|
11
|
+
schemas: OpenAPISchema[];
|
|
12
|
+
context: OpenAPIContextInput;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to show the schema directly if there is only one.
|
|
15
|
+
*/
|
|
16
|
+
grouped?: boolean;
|
|
17
|
+
}): react2.JSX.Element | null;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { OpenAPISchemas };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { t } from "../translate.js";
|
|
2
|
+
import { OpenAPIExample } from "../OpenAPIExample.js";
|
|
3
|
+
import { OpenAPIRootSchema } from "../OpenAPISchemaServer.js";
|
|
4
|
+
import { StaticSection } from "../StaticSection.js";
|
|
5
|
+
import { getOpenAPIClientContext, resolveOpenAPIContext } from "../context.js";
|
|
6
|
+
import { getExampleFromSchema } from "../util/example.js";
|
|
7
|
+
import { OpenAPISchemaItem } from "./OpenAPISchemaItem.js";
|
|
8
|
+
import clsx from "classnames";
|
|
9
|
+
|
|
10
|
+
//#region src/schemas/OpenAPISchemas.tsx
|
|
11
|
+
/**
|
|
12
|
+
* OpenAPI Schemas component.
|
|
13
|
+
*/
|
|
14
|
+
function OpenAPISchemas(props) {
|
|
15
|
+
const { schemas, context: contextInput, grouped, className } = props;
|
|
16
|
+
const firstSchema = schemas[0];
|
|
17
|
+
if (!firstSchema) return null;
|
|
18
|
+
const context = resolveOpenAPIContext(contextInput);
|
|
19
|
+
const clientContext = getOpenAPIClientContext(context);
|
|
20
|
+
if (schemas.length === 1 && !grouped) {
|
|
21
|
+
const title = `The ${firstSchema.name} object`;
|
|
22
|
+
return <div className={clsx("openapi-schemas", className)}>
|
|
23
|
+
<div className="openapi-summary" id={context.id}>
|
|
24
|
+
{context.renderHeading({
|
|
25
|
+
title,
|
|
26
|
+
deprecated: Boolean(firstSchema.schema.deprecated),
|
|
27
|
+
stability: firstSchema.schema["x-stability"]
|
|
28
|
+
})}
|
|
29
|
+
</div>
|
|
30
|
+
<div className="openapi-columns">
|
|
31
|
+
<div className="openapi-column-spec">
|
|
32
|
+
<StaticSection className="openapi-parameters" header={t(context.translation, "attributes")}>
|
|
33
|
+
<OpenAPIRootSchema schema={firstSchema.schema} context={clientContext} />
|
|
34
|
+
</StaticSection>
|
|
35
|
+
</div>
|
|
36
|
+
<div className="openapi-column-preview">
|
|
37
|
+
<div className="openapi-column-preview-body">
|
|
38
|
+
<div className="openapi-panel">
|
|
39
|
+
<h4 className="openapi-panel-heading">{title}</h4>
|
|
40
|
+
<div className="openapi-panel-body">
|
|
41
|
+
<OpenAPIExample example={getExampleFromSchema({ schema: firstSchema.schema })} context={context} syntax="json" />
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>;
|
|
48
|
+
}
|
|
49
|
+
return <div className={clsx("openapi-schemas", className)}>
|
|
50
|
+
{schemas.map(({ name, schema }) => {
|
|
51
|
+
return <OpenAPISchemaItem key={name} name={name} context={clientContext} schema={schema} />;
|
|
52
|
+
})}
|
|
53
|
+
</div>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { OpenAPISchemas };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Filesystem, OpenAPISchema, OpenAPIV3xDocument } from "@gitbook/openapi-parser";
|
|
2
|
+
|
|
3
|
+
//#region src/schemas/resolveOpenAPISchemas.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolve an OpenAPI schemas from a file and compile it to a more usable format.
|
|
7
|
+
* Schemas are extracted from the OpenAPI components.schemas
|
|
8
|
+
*/
|
|
9
|
+
declare function resolveOpenAPISchemas(filesystem: Filesystem<OpenAPIV3xDocument>, options: {
|
|
10
|
+
schemas: string[];
|
|
11
|
+
}): Promise<{
|
|
12
|
+
schemas: OpenAPISchema[];
|
|
13
|
+
} | null>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { resolveOpenAPISchemas };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { dereferenceFilesystem } from "../dereference.js";
|
|
2
|
+
import { filterSelectedOpenAPISchemas } from "@gitbook/openapi-parser";
|
|
3
|
+
|
|
4
|
+
//#region src/schemas/resolveOpenAPISchemas.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolve an OpenAPI schemas from a file and compile it to a more usable format.
|
|
7
|
+
* Schemas are extracted from the OpenAPI components.schemas
|
|
8
|
+
*/
|
|
9
|
+
async function resolveOpenAPISchemas(filesystem, options) {
|
|
10
|
+
const { schemas: selectedSchemas } = options;
|
|
11
|
+
const schemas = filterSelectedOpenAPISchemas(await dereferenceFilesystem(filesystem), selectedSchemas);
|
|
12
|
+
if (schemas.length === 0) return null;
|
|
13
|
+
return { schemas };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { resolveOpenAPISchemas };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/stringifyOpenAPI.ts
|
|
2
|
+
/**
|
|
3
|
+
* Stringify an OpenAPI object. Same API as JSON.stringify.
|
|
4
|
+
*/
|
|
5
|
+
function stringifyOpenAPI(value, replacer, space) {
|
|
6
|
+
return JSON.stringify(value, (key, value$1) => {
|
|
7
|
+
if (key.startsWith("x-gitbook-")) return;
|
|
8
|
+
if (replacer) return replacer(key, value$1);
|
|
9
|
+
return value$1;
|
|
10
|
+
}, space);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { stringifyOpenAPI };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { isValidElement } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/translate.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Translate a string.
|
|
6
|
+
*/
|
|
7
|
+
function t(translation, id, ...args) {
|
|
8
|
+
const string = translation[id];
|
|
9
|
+
if (!string) throw new Error(`Translation not found for "${id}"`);
|
|
10
|
+
const parts = [];
|
|
11
|
+
let currentStringToReplace = string;
|
|
12
|
+
args.forEach((arg, i) => {
|
|
13
|
+
if (typeof arg === "string") currentStringToReplace = currentStringToReplace.replace(`\${${i + 1}}`, arg);
|
|
14
|
+
else {
|
|
15
|
+
const [partToPush, partToReplace] = currentStringToReplace.split(`\${${i + 1}}`);
|
|
16
|
+
if (partToPush === void 0 || partToReplace === void 0) throw new Error(`Invalid translation "${id}"`);
|
|
17
|
+
parts.push(<React.Fragment key={`string-${i}`}>{partToPush}</React.Fragment>);
|
|
18
|
+
parts.push(<React.Fragment key={`arg-${i}`}>{arg}</React.Fragment>);
|
|
19
|
+
currentStringToReplace = partToReplace;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
if (!parts.length) return currentStringToReplace;
|
|
23
|
+
return <>
|
|
24
|
+
{parts}
|
|
25
|
+
{currentStringToReplace}
|
|
26
|
+
</>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Version of `t` that returns a string.
|
|
30
|
+
*/
|
|
31
|
+
function tString(translation, id, ...args) {
|
|
32
|
+
return reactToString(t(translation, id, ...args));
|
|
33
|
+
}
|
|
34
|
+
function reactToString(el) {
|
|
35
|
+
if (typeof el === "string" || typeof el === "number" || typeof el === "boolean") return `${el}`;
|
|
36
|
+
if (el === null || el === void 0) return "";
|
|
37
|
+
if (Array.isArray(el)) return el.map(reactToString).join("");
|
|
38
|
+
if (isValidElement(el)) return el.props.children.map(reactToString).join("");
|
|
39
|
+
throw new Error(`Unsupported type ${typeof el}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { t, tString };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/translations/de.ts
|
|
2
|
+
const de = {
|
|
3
|
+
required: "Erforderlich",
|
|
4
|
+
deprecated: "Veraltet",
|
|
5
|
+
deprecated_and_sunset_on: "Diese Operation ist veraltet und wird am ${1} eingestellt.",
|
|
6
|
+
stability_experimental: "Experimentell",
|
|
7
|
+
stability_alpha: "Alpha",
|
|
8
|
+
stability_beta: "Beta",
|
|
9
|
+
discriminator: "Diskriminator",
|
|
10
|
+
copy_to_clipboard: "In die Zwischenablage kopieren",
|
|
11
|
+
copied: "Kopiert",
|
|
12
|
+
no_content: "Kein Inhalt",
|
|
13
|
+
unresolved_reference: "Nicht aufgelöste Referenz",
|
|
14
|
+
circular_reference: "Zirkuläre Referenz",
|
|
15
|
+
read_only: "Nur lesen",
|
|
16
|
+
write_only: "Nur schreiben",
|
|
17
|
+
optional: "Optional",
|
|
18
|
+
min: "Min",
|
|
19
|
+
max: "Max",
|
|
20
|
+
nullable: "Nullfähig",
|
|
21
|
+
body: "Rumpf",
|
|
22
|
+
payload: "Nutzlast",
|
|
23
|
+
headers: "Header",
|
|
24
|
+
header: "Header",
|
|
25
|
+
authorizations: "Autorisierungen",
|
|
26
|
+
responses: "Antworten",
|
|
27
|
+
response: "Antwort",
|
|
28
|
+
path_parameters: "Pfadparameter",
|
|
29
|
+
query_parameters: "Abfrageparameter",
|
|
30
|
+
header_parameters: "Header-Parameter",
|
|
31
|
+
attributes: "Attribute",
|
|
32
|
+
test_it: "Teste es",
|
|
33
|
+
information: "Information",
|
|
34
|
+
success: "Erfolg",
|
|
35
|
+
redirect: "Umleitung",
|
|
36
|
+
error: "Fehler",
|
|
37
|
+
show: "Zeige ${1}",
|
|
38
|
+
hide: "Verstecke ${1}",
|
|
39
|
+
available_items: "Verfügbare Elemente",
|
|
40
|
+
required_scopes: "Erforderliche Scopes",
|
|
41
|
+
required_scopes_description: "Dieser Endpunkt erfordert die folgenden Scopes:",
|
|
42
|
+
available_scopes: "Verfügbare Scopes:",
|
|
43
|
+
properties: "Eigenschaften",
|
|
44
|
+
or: "oder",
|
|
45
|
+
and: "und",
|
|
46
|
+
possible_values: "Mögliche Werte"
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { de };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region src/translations/en.d.ts
|
|
2
|
+
declare const en: {
|
|
3
|
+
required: string;
|
|
4
|
+
deprecated: string;
|
|
5
|
+
deprecated_and_sunset_on: string;
|
|
6
|
+
stability_experimental: string;
|
|
7
|
+
stability_alpha: string;
|
|
8
|
+
stability_beta: string;
|
|
9
|
+
discriminator: string;
|
|
10
|
+
copy_to_clipboard: string;
|
|
11
|
+
copied: string;
|
|
12
|
+
no_content: string;
|
|
13
|
+
unresolved_reference: string;
|
|
14
|
+
circular_reference: string;
|
|
15
|
+
read_only: string;
|
|
16
|
+
write_only: string;
|
|
17
|
+
optional: string;
|
|
18
|
+
min: string;
|
|
19
|
+
max: string;
|
|
20
|
+
nullable: string;
|
|
21
|
+
body: string;
|
|
22
|
+
payload: string;
|
|
23
|
+
headers: string;
|
|
24
|
+
header: string;
|
|
25
|
+
authorizations: string;
|
|
26
|
+
responses: string;
|
|
27
|
+
response: string;
|
|
28
|
+
path_parameters: string;
|
|
29
|
+
query_parameters: string;
|
|
30
|
+
header_parameters: string;
|
|
31
|
+
attributes: string;
|
|
32
|
+
test_it: string;
|
|
33
|
+
information: string;
|
|
34
|
+
success: string;
|
|
35
|
+
redirect: string;
|
|
36
|
+
error: string;
|
|
37
|
+
show: string;
|
|
38
|
+
hide: string;
|
|
39
|
+
available_items: string;
|
|
40
|
+
required_scopes: string;
|
|
41
|
+
required_scopes_description: string;
|
|
42
|
+
available_scopes: string;
|
|
43
|
+
possible_values: string;
|
|
44
|
+
properties: string;
|
|
45
|
+
or: string;
|
|
46
|
+
and: string;
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { en };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/translations/en.ts
|
|
2
|
+
const en = {
|
|
3
|
+
required: "Required",
|
|
4
|
+
deprecated: "Deprecated",
|
|
5
|
+
deprecated_and_sunset_on: "This operation is deprecated and will be sunset on ${1}.",
|
|
6
|
+
stability_experimental: "Experimental",
|
|
7
|
+
stability_alpha: "Alpha",
|
|
8
|
+
stability_beta: "Beta",
|
|
9
|
+
discriminator: "Discriminator",
|
|
10
|
+
copy_to_clipboard: "Copy to clipboard",
|
|
11
|
+
copied: "Copied",
|
|
12
|
+
no_content: "No content",
|
|
13
|
+
unresolved_reference: "Unresolved reference",
|
|
14
|
+
circular_reference: "Circular reference",
|
|
15
|
+
read_only: "Read-only",
|
|
16
|
+
write_only: "Write-only",
|
|
17
|
+
optional: "Optional",
|
|
18
|
+
min: "Min",
|
|
19
|
+
max: "Max",
|
|
20
|
+
nullable: "Nullable",
|
|
21
|
+
body: "Body",
|
|
22
|
+
payload: "Payload",
|
|
23
|
+
headers: "Headers",
|
|
24
|
+
header: "Header",
|
|
25
|
+
authorizations: "Authorizations",
|
|
26
|
+
responses: "Responses",
|
|
27
|
+
response: "Response",
|
|
28
|
+
path_parameters: "Path parameters",
|
|
29
|
+
query_parameters: "Query parameters",
|
|
30
|
+
header_parameters: "Header parameters",
|
|
31
|
+
attributes: "Attributes",
|
|
32
|
+
test_it: "Test it",
|
|
33
|
+
information: "Information",
|
|
34
|
+
success: "Success",
|
|
35
|
+
redirect: "Redirect",
|
|
36
|
+
error: "Error",
|
|
37
|
+
show: "Show ${1}",
|
|
38
|
+
hide: "Hide ${1}",
|
|
39
|
+
available_items: "Available items",
|
|
40
|
+
required_scopes: "Required scopes",
|
|
41
|
+
required_scopes_description: "This endpoint requires the following scopes:",
|
|
42
|
+
available_scopes: "Available scopes:",
|
|
43
|
+
possible_values: "Possible values",
|
|
44
|
+
properties: "Properties",
|
|
45
|
+
or: "or",
|
|
46
|
+
and: "and"
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { en };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/translations/es.ts
|
|
2
|
+
const es = {
|
|
3
|
+
required: "Requerido",
|
|
4
|
+
deprecated: "Obsoleto",
|
|
5
|
+
deprecated_and_sunset_on: "Esta operación está obsoleta y se retirará el ${1}.",
|
|
6
|
+
stability_experimental: "Experimental",
|
|
7
|
+
stability_alpha: "Alfa",
|
|
8
|
+
stability_beta: "Beta",
|
|
9
|
+
discriminator: "Discriminador",
|
|
10
|
+
copy_to_clipboard: "Copiar al portapapeles",
|
|
11
|
+
copied: "Copiado",
|
|
12
|
+
no_content: "Sin contenido",
|
|
13
|
+
unresolved_reference: "Referencia no resuelta",
|
|
14
|
+
circular_reference: "Referencia circular",
|
|
15
|
+
read_only: "Solo lectura",
|
|
16
|
+
write_only: "Solo escritura",
|
|
17
|
+
optional: "Opcional",
|
|
18
|
+
min: "Mín",
|
|
19
|
+
max: "Máx",
|
|
20
|
+
nullable: "Nulo",
|
|
21
|
+
body: "Cuerpo",
|
|
22
|
+
payload: "Caga útil",
|
|
23
|
+
headers: "Headers",
|
|
24
|
+
header: "Header",
|
|
25
|
+
authorizations: "Autorizaciones",
|
|
26
|
+
responses: "Respuestas",
|
|
27
|
+
response: "Respuesta",
|
|
28
|
+
path_parameters: "Parámetros de ruta",
|
|
29
|
+
query_parameters: "Parámetros de consulta",
|
|
30
|
+
header_parameters: "Parámetros de encabezado",
|
|
31
|
+
attributes: "Atributos",
|
|
32
|
+
test_it: "Pruébalo",
|
|
33
|
+
information: "Información",
|
|
34
|
+
success: "Éxito",
|
|
35
|
+
redirect: "Redirección",
|
|
36
|
+
error: "Error",
|
|
37
|
+
show: "Mostrar ${1}",
|
|
38
|
+
hide: "Ocultar ${1}",
|
|
39
|
+
available_items: "Elementos disponibles",
|
|
40
|
+
required_scopes: "Scopes requeridos",
|
|
41
|
+
required_scopes_description: "Este endpoint requiere los siguientes scopes:",
|
|
42
|
+
available_scopes: "Scopes disponibles:",
|
|
43
|
+
properties: "Propiedades",
|
|
44
|
+
or: "o",
|
|
45
|
+
and: "y",
|
|
46
|
+
possible_values: "Valores posibles"
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { es };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/translations/fr.ts
|
|
2
|
+
const fr = {
|
|
3
|
+
required: "Requis",
|
|
4
|
+
deprecated: "Obsolète",
|
|
5
|
+
deprecated_and_sunset_on: "Cette opération est obsolète et sera supprimée le ${1}.",
|
|
6
|
+
stability_experimental: "Expérimental",
|
|
7
|
+
stability_alpha: "Alpha",
|
|
8
|
+
stability_beta: "Bêta",
|
|
9
|
+
discriminator: "Discriminateur",
|
|
10
|
+
copy_to_clipboard: "Copier dans le presse-papiers",
|
|
11
|
+
copied: "Copié",
|
|
12
|
+
no_content: "Aucun contenu",
|
|
13
|
+
unresolved_reference: "Référence non résolue",
|
|
14
|
+
circular_reference: "Référence circulaire",
|
|
15
|
+
read_only: "Lecture seule",
|
|
16
|
+
write_only: "Écriture seule",
|
|
17
|
+
optional: "Optionnel",
|
|
18
|
+
min: "Min",
|
|
19
|
+
max: "Max",
|
|
20
|
+
nullable: "Nullable",
|
|
21
|
+
body: "Corps",
|
|
22
|
+
payload: "Charge utile",
|
|
23
|
+
headers: "Headers",
|
|
24
|
+
header: "Header",
|
|
25
|
+
authorizations: "Autorisations",
|
|
26
|
+
responses: "Réponses",
|
|
27
|
+
response: "Réponse",
|
|
28
|
+
path_parameters: "Paramètres de chemin",
|
|
29
|
+
query_parameters: "Paramètres de requête",
|
|
30
|
+
header_parameters: "Paramètres d'en-tête",
|
|
31
|
+
attributes: "Attributs",
|
|
32
|
+
test_it: "Tester",
|
|
33
|
+
information: "Information",
|
|
34
|
+
success: "Succès",
|
|
35
|
+
redirect: "Redirection",
|
|
36
|
+
error: "Erreur",
|
|
37
|
+
show: "Afficher ${1}",
|
|
38
|
+
hide: "Masquer ${1}",
|
|
39
|
+
available_items: "Éléments disponibles",
|
|
40
|
+
required_scopes: "Scopes requis",
|
|
41
|
+
required_scopes_description: "Cet endpoint nécessite les scopes suivants:",
|
|
42
|
+
available_scopes: "Scopes disponibles:",
|
|
43
|
+
properties: "Propriétés",
|
|
44
|
+
or: "ou",
|
|
45
|
+
and: "et",
|
|
46
|
+
possible_values: "Valeurs possibles"
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { fr };
|