MCPcopy Index your code
hub / github.com/GitbookIO/gitbook / OpenAPIResponse

Function OpenAPIResponse

packages/react-openapi/src/OpenAPIResponseExample.tsx:105–151  ·  view source on GitHub ↗
(props: {
    context: OpenAPIContext;
    content: {
        [media: string]: OpenAPIV3.MediaTypeObject | null;
    };
})

Source from the content-addressed store, hash-verified

103}
104
105function OpenAPIResponse(props: {
106 context: OpenAPIContext;
107 content: {
108 [media: string]: OpenAPIV3.MediaTypeObject | null;
109 };
110}) {
111 const { context, content } = props;
112
113 const entries = Object.entries(content);
114 const firstEntry = entries[0];
115
116 if (!firstEntry) {
117 throw new Error('One media type is required');
118 }
119
120 const tabs = entries.map((entry) => {
121 const [mediaType, mediaTypeObject] = entry;
122
123 if (!mediaTypeObject) {
124 return {
125 key: mediaType,
126 label: mediaType,
127 body: <OpenAPIEmptyExample context={context} />,
128 };
129 }
130
131 return {
132 key: mediaType,
133 label: mediaType,
134 body: <></>,
135 examples: getExamples({
136 mediaTypeObject,
137 mediaType,
138 context,
139 }),
140 };
141 });
142
143 return (
144 <OpenAPIMediaTypeContent
145 selectIcon={context.icons.chevronDown}
146 stateKey={createStateKey('response-media-types', context.blockKey)}
147 items={tabs}
148 context={getOpenAPIClientContext(context)}
149 />
150 );
151}

Callers

nothing calls this directly

Calls 3

getExamplesFunction · 0.90
createStateKeyFunction · 0.90
getOpenAPIClientContextFunction · 0.90

Tested by

no test coverage detected