@gitbook/react-openapi 1.1.8 → 1.1.10
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 +21 -0
- package/dist/InteractiveSection.jsx +7 -6
- package/dist/OpenAPICodeSample.d.ts +2 -2
- package/dist/OpenAPICodeSample.jsx +3 -8
- package/dist/OpenAPICodeSampleInteractive.jsx +31 -19
- package/dist/OpenAPICodeSampleSelector.d.ts +15 -0
- package/dist/OpenAPICodeSampleSelector.jsx +49 -0
- package/dist/OpenAPIExample.d.ts +34 -0
- package/dist/OpenAPIExample.jsx +103 -0
- package/dist/OpenAPIOperation.d.ts +2 -2
- package/dist/OpenAPIOperation.jsx +3 -7
- package/dist/OpenAPIPath.d.ts +10 -2
- package/dist/OpenAPIPath.jsx +9 -4
- package/dist/OpenAPIResponse.jsx +3 -3
- package/dist/OpenAPIResponseExample.d.ts +2 -2
- package/dist/OpenAPIResponseExample.jsx +4 -90
- package/dist/OpenAPIResponses.jsx +23 -10
- package/dist/OpenAPISchema.jsx +26 -15
- package/dist/OpenAPISchemaName.jsx +2 -7
- package/dist/OpenAPISecurities.jsx +6 -6
- package/dist/OpenAPISelect.d.ts +15 -0
- package/dist/OpenAPISelect.jsx +32 -0
- package/dist/OpenAPITabs.jsx +9 -9
- package/dist/context.d.ts +54 -0
- package/dist/context.js +11 -0
- package/dist/generateSchemaExample.d.ts +1 -1
- package/dist/generateSchemaExample.js +28 -26
- package/dist/getOrCreateStoreByKey.d.ts +10 -0
- package/dist/getOrCreateStoreByKey.js +20 -0
- package/dist/index.d.ts +1 -1
- package/dist/resolveOpenAPIOperation.js +10 -5
- package/dist/schemas/OpenAPISchemas.d.ts +5 -6
- package/dist/schemas/OpenAPISchemas.jsx +45 -38
- package/dist/schemas/resolveOpenAPISchemas.d.ts +4 -3
- package/dist/schemas/resolveOpenAPISchemas.js +0 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types.d.ts +32 -26
- package/package.json +1 -1
- package/src/InteractiveSection.tsx +10 -8
- package/src/OpenAPICodeSample.tsx +8 -15
- package/src/OpenAPICodeSampleInteractive.tsx +43 -26
- package/src/OpenAPICodeSampleSelector.tsx +87 -0
- package/src/OpenAPIExample.tsx +129 -0
- package/src/OpenAPIOperation.tsx +6 -10
- package/src/OpenAPIPath.tsx +23 -6
- package/src/OpenAPIResponse.tsx +9 -7
- package/src/OpenAPIResponseExample.tsx +13 -113
- package/src/OpenAPIResponses.tsx +37 -12
- package/src/OpenAPISchema.tsx +40 -25
- package/src/OpenAPISchemaName.tsx +2 -8
- package/src/OpenAPISecurities.tsx +22 -9
- package/src/OpenAPISelect.tsx +70 -0
- package/src/OpenAPITabs.tsx +9 -9
- package/src/context.ts +64 -0
- package/src/generateSchemaExample.test.ts +1020 -0
- package/src/generateSchemaExample.ts +103 -36
- package/src/getOrCreateStoreByKey.ts +35 -0
- package/src/index.ts +1 -1
- package/src/resolveOpenAPIOperation.ts +14 -3
- package/src/schemas/OpenAPISchemas.tsx +75 -70
- package/src/schemas/resolveOpenAPISchemas.ts +4 -5
- package/src/types.ts +36 -29
- package/dist/useSyncedTabsGlobalState.d.ts +0 -10
- package/dist/useSyncedTabsGlobalState.js +0 -20
- package/src/useSyncedTabsGlobalState.ts +0 -35
|
@@ -1,62 +1,69 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import { OpenAPIDisclosureGroup } from '../OpenAPIDisclosureGroup';
|
|
3
|
+
import { OpenAPIExample, getExampleFromSchema } from '../OpenAPIExample';
|
|
3
4
|
import { OpenAPIRootSchema } from '../OpenAPISchemaServer';
|
|
4
|
-
import { Section, SectionBody } from '../StaticSection';
|
|
5
|
+
import { Section, SectionBody, StaticSection } from '../StaticSection';
|
|
6
|
+
import { getOpenAPIClientContext } from '../context';
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* OpenAPI Schemas component.
|
|
7
9
|
*/
|
|
8
10
|
export function OpenAPISchemas(props) {
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
defaultInteractiveOpened: context.defaultInteractiveOpened,
|
|
13
|
-
icons: context.icons,
|
|
14
|
-
blockKey: context.blockKey,
|
|
15
|
-
};
|
|
16
|
-
if (!schemas.length) {
|
|
11
|
+
var schemas = props.schemas, context = props.context, grouped = props.grouped, className = props.className;
|
|
12
|
+
var firstSchema = schemas[0];
|
|
13
|
+
if (!firstSchema) {
|
|
17
14
|
return null;
|
|
18
15
|
}
|
|
19
|
-
|
|
20
|
-
<OpenAPIRootSchemasSchema grouped={grouped} schemas={schemas} context={clientContext}/>
|
|
21
|
-
</div>);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Root schema for OpenAPI schemas.
|
|
25
|
-
* It displays a single model or a disclosure group for multiple schemas.
|
|
26
|
-
*/
|
|
27
|
-
function OpenAPIRootSchemasSchema(props) {
|
|
28
|
-
var _a;
|
|
29
|
-
var schemas = props.schemas, context = props.context, grouped = props.grouped;
|
|
16
|
+
var clientContext = getOpenAPIClientContext(context);
|
|
30
17
|
// If there is only one model and we are not grouping, we show it directly.
|
|
31
18
|
if (schemas.length === 1 && !grouped) {
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
19
|
+
var title = "The ".concat(firstSchema.name, " object");
|
|
20
|
+
return (<div className={clsx('openapi-schemas', className)}>
|
|
21
|
+
<div className="openapi-summary" id={context.id}>
|
|
22
|
+
{context.renderHeading({
|
|
23
|
+
title: title,
|
|
24
|
+
})}
|
|
25
|
+
</div>
|
|
26
|
+
<div className="openapi-columns">
|
|
27
|
+
<div className="openapi-column-spec">
|
|
28
|
+
<StaticSection className="openapi-parameters" header="Attributes">
|
|
29
|
+
<OpenAPIRootSchema schema={firstSchema.schema} context={clientContext}/>
|
|
30
|
+
</StaticSection>
|
|
31
|
+
</div>
|
|
32
|
+
<div className="openapi-column-preview">
|
|
33
|
+
<div className="openapi-column-preview-body">
|
|
34
|
+
<div className="openapi-panel">
|
|
35
|
+
<h4 className="openapi-panel-heading">{title}</h4>
|
|
36
|
+
<div className="openapi-panel-body">
|
|
37
|
+
<OpenAPIExample example={getExampleFromSchema({
|
|
38
|
+
schema: firstSchema.schema,
|
|
39
|
+
})} context={context} syntax="json"/>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>);
|
|
41
46
|
}
|
|
42
47
|
// If there are multiple schemas, we use a disclosure group to show them all.
|
|
43
|
-
return (<
|
|
48
|
+
return (<div className={clsx('openapi-schemas', className)}>
|
|
49
|
+
<OpenAPIDisclosureGroup allowsMultipleExpanded icon={context.icons.chevronRight} groups={schemas.map(function (_a) {
|
|
44
50
|
var name = _a.name, schema = _a.schema;
|
|
45
51
|
return ({
|
|
46
52
|
id: name,
|
|
47
53
|
label: (<div className="openapi-response-tab-content" key={"model-".concat(name)}>
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
<span className="openapi-response-statuscode">{name}</span>
|
|
55
|
+
</div>),
|
|
50
56
|
tabs: [
|
|
51
57
|
{
|
|
52
58
|
id: 'model',
|
|
53
59
|
body: (<Section className="openapi-section-schemas">
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
<SectionBody>
|
|
61
|
+
<OpenAPIRootSchema schema={schema} context={clientContext}/>
|
|
62
|
+
</SectionBody>
|
|
63
|
+
</Section>),
|
|
58
64
|
},
|
|
59
65
|
],
|
|
60
66
|
});
|
|
61
|
-
})}/>
|
|
67
|
+
})}/>
|
|
68
|
+
</div>);
|
|
62
69
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { Filesystem, OpenAPIV3xDocument } from '@gitbook/openapi-parser';
|
|
2
|
-
import type { OpenAPISchemasData } from '../types';
|
|
1
|
+
import type { Filesystem, OpenAPISchema, OpenAPIV3xDocument } from '@gitbook/openapi-parser';
|
|
3
2
|
/**
|
|
4
3
|
* Resolve an OpenAPI schemas from a file and compile it to a more usable format.
|
|
5
4
|
* Schemas are extracted from the OpenAPI components.schemas
|
|
6
5
|
*/
|
|
7
6
|
export declare function resolveOpenAPISchemas(filesystem: Filesystem<OpenAPIV3xDocument>, options: {
|
|
8
7
|
schemas: string[];
|
|
9
|
-
}): Promise<
|
|
8
|
+
}): Promise<{
|
|
9
|
+
schemas: OpenAPISchema[];
|
|
10
|
+
} | null>;
|
|
@@ -36,7 +36,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import { filterSelectedOpenAPISchemas } from '@gitbook/openapi-parser';
|
|
38
38
|
import { dereferenceFilesystem } from '../dereference';
|
|
39
|
-
//!!TODO: We should return only the schemas that are used in the block. Still a WIP awaiting future work.
|
|
40
39
|
/**
|
|
41
40
|
* Resolve an OpenAPI schemas from a file and compile it to a more usable format.
|
|
42
41
|
* Schemas are extracted from the OpenAPI components.schemas
|