MCPcopy
hub / github.com/rapi-doc/RapiDoc / getComponents

Function getComponents

src/utils/spec-parser.js:235–314  ·  view source on GitHub ↗
(openApiSpec, sortSchemas = false)

Source from the content-addressed store, hash-verified

233}
234
235function getComponents(openApiSpec, sortSchemas = false) {
236 if (!openApiSpec.components) {
237 return [];
238 }
239 const components = [];
240 for (const component in openApiSpec.components) {
241 const subComponents = [];
242 for (const sComponent in openApiSpec.components[component]) {
243 const scmp = {
244 show: true,
245 id: `${component.toLowerCase()}-${sComponent.toLowerCase()}`.replace(invalidCharsRegEx, '-'),
246 name: sComponent,
247 component: openApiSpec.components[component][sComponent],
248 };
249 subComponents.push(scmp);
250 }
251
252 let cmpDescription = component;
253 let cmpName = component;
254
255 switch (component) {
256 case 'schemas':
257 if (sortSchemas) {
258 subComponents.sort((c1, c2) => c1.name.localeCompare(c2.name));
259 }
260
261 cmpName = 'Schemas';
262 cmpDescription = 'Schemas allows the definition of input and output data types. These types can be objects, but also primitives and arrays.';
263 break;
264 case 'responses':
265 cmpName = 'Responses';
266 cmpDescription = 'Describes responses from an API Operation, including design-time, static links to operations based on the response.';
267 break;
268 case 'parameters':
269 cmpName = 'Parameters';
270 cmpDescription = 'Describes operation parameters. A unique parameter is defined by a combination of a name and location.';
271 break;
272 case 'examples':
273 cmpName = 'Examples';
274 cmpDescription = 'List of Examples for operations, can be requests, responses and objects examples.';
275 break;
276 case 'requestBodies':
277 cmpName = 'Request Bodies';
278 cmpDescription = 'Describes common request bodies that are used across the API operations.';
279 break;
280 case 'headers':
281 cmpName = 'Headers';
282 cmpDescription = 'Headers follows the structure of the Parameters but they are explicitly in "header"';
283 break;
284 case 'securitySchemes':
285 cmpName = 'Security Schemes';
286 // eslint-disable-next-line max-len
287 cmpDescription = 'Defines a security scheme that can be used by the operations. Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), OAuth2\'s common flows(implicit, password, client credentials and authorization code) as defined in RFC6749, and OpenID Connect Discovery.';
288 break;
289 case 'links':
290 cmpName = 'Links';
291 cmpDescription = 'Links represent a possible design-time link for a response. The presence of a link does not guarantee the caller\'s ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations.';
292 break;

Callers 1

ProcessSpecFunction · 0.70

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…