Skip to content

poor type definitions for config #1195

@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

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy