1.2.0 • Published 6 months ago

@pusula/swagger-codegen v1.2.0

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

@pusula/swagger-codegen

NPM badge

Generates swagger types and module.core providers with using swagger-typescript-api

Getting Started

Install package and dependencies

npm

npm i --save-dev @pusula/swagger-codegen swagger-typescript-api
npm i @pusula/module.core

pnpm

pnpm i -D @pusula/swagger-codegen swagger-typescript-api
pnpm i @pusula/module.core

yarn

yarn add -dev @pusula/swagger-codegen swagger-typescript-api
yarn add @pusula/module.core

Usage

This will generate api types and @pusula/module.core providers.

import { generate } from "@pusula/swagger-codegen";

generate({
    //output files will be placed under /src/__generated__ if you dont provide a output param
    //output: path.resolve(process.cwd(), "./src/__generated__"),
    //templates: path.resolve(__dirname,"./src/templates")
    url: "http://api.com/swagger.json",
});

Usage For Multiple Endpoints

This will generate api types and @pusula/module.core providers for multiple endpoints in different folders.

It detects duplicate of types and providers and adds suffix numbers like 'ProductApi2' to the end.

Provide optional wordMapForReplacingInTypeNames object to replace some words.

import { generate, GenerateApiMultipleOptions } from "@pusula/swagger-codegen";

const endpoints: GenerateApiMultipleOptions = {
    endpoints: [
        { name: "auth", url: "http://api.com/auth/swagger.json" },
        { name: "products", url: "http://api.com/products/swagger.json" },
        {
            name: "products-v2",
            url: "http://api.com/products/swagger.json",
        },
    ],
    authorizationToken: autToken,
    wordMapForReplacingInTypeNames: {'ExtraLongWord':'ELW'}
    ...
};

generateMultiple({
    endPoints,
});

Check the @pusula/module.core documentation for more details. For more customization options check the documentation of swagger-typescript-api

1.2.0

6 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.1.9

7 months ago

1.1.8

7 months ago

1.1.7

7 months ago

1.1.6

8 months ago

1.1.5

8 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.10

6 months ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago