MCPcopy Create free account
hub / github.com/axe-api/axe-api / generateDocumentation

Function generateDocumentation

packages/axe-api/src/Builders/SwaggerBuilder.ts:549–682  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

547};
548
549const generateDocumentation = async () => {
550 const docs = DocumentationService.getInstance();
551 const api = APIService.getInstance();
552
553 let baseSchema = {
554 info: {
555 title: "Axe API",
556 description: "Edit your swagger/index.ts file",
557 },
558 servers: [
559 {
560 url: "http://localhost:3000",
561 },
562 ],
563 };
564
565 const swaggerBasePath = path.join(api.appFolder, "swagger");
566 if (
567 fs.existsSync(`${swaggerBasePath}.ts`) ||
568 fs.existsSync(`${swaggerBasePath}.js`)
569 ) {
570 const { default: userDefinedSchema } = await import(swaggerBasePath);
571 baseSchema = userDefinedSchema;
572 }
573
574 const schemas: any = {};
575 const requestBodies: any = {};
576 const firstVersion = api.versions.at(0);
577
578 if (!firstVersion) {
579 throw new Error("The version is not found!");
580 }
581
582 for (const model of firstVersion.modelList.get()) {
583 const properties: any = {};
584 for (const column of model.columns) {
585 properties[column.name] = {
586 type: toPropertyType(column.data_type),
587 format: column.data_type,
588 };
589 }
590 schemas[model.name] = {
591 type: "object",
592 properties,
593 };
594
595 if (model.instance.handlers.includes(HandlerTypes.INSERT)) {
596 requestBodies[`${model.name}${pascalCase(HttpMethods.POST)}Body`] = {
597 type: "object",
598 properties: toFillableFieldProperties(model),
599 };
600 }
601
602 if (model.instance.handlers.includes(HandlerTypes.UPDATE)) {
603 requestBodies[`${model.name}${pascalCase(HttpMethods.PUT)}Body`] = {
604 type: "object",
605 properties: toFillableFieldProperties(model),
606 };

Callers 1

SwaggerBuilder.tsFile · 0.85

Calls 14

toPropertyTypeFunction · 0.85
normalizeSwaggerPathFunction · 0.85
toEndpointSummaryFunction · 0.85
toEndpointDescriptionFunction · 0.85
toEndpointResponseFunction · 0.85
toRequestParametersFunction · 0.85
toRequestBodyFunction · 0.85
deepMergeFunction · 0.85
getCustomsMethod · 0.80
findMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected