Skip to content

poor type definitions for config #1195

Open
@arashi-dev

Description

@arashi-dev

This code works as expected. However, some of the properties (templates and Ts in this case) are not defined in config's typescript types. and I am getting ts errors on them. I am using version: 13.1.1

import path from "path";
import { generateApi } from "swagger-typescript-api";

const basePath = path.resolve(process.cwd(), "./src/core/lib/@acme/api");

const run = async () => {
  await generateApi({
    fileName: "generatedApi.ts",
    output: path.resolve(basePath, "__generated__"),
    url: "http://localhost:4000/swagger/json",
    generateResponses: true,
    defaultResponseAsSuccess: true,
    disableThrowOnError: true,
    hooks: {
      onFormatRouteName(routeInfo) {
        return routeInfo.operationId.replaceAll(".", "_");
      },
    },
    templates: path.resolve(basePath, "templates"),
    Ts: {
      IntersectionType: (contents) => {
        const items = contents as string[];

        return items.slice(1).reduce((a, b) => `Merge<${a}, ${b}>`, items[0])!;
      },
    },
  });
};

void run();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions