Skip to content

Releases: Himenon/openapi-typescript-code-generator

@himenon/[email protected]

@himenon/[email protected]

27 Apr 09:12
Compare
Choose a tag to compare

@himenon/[email protected]

08 Apr 15:17
Compare
Choose a tag to compare

@himenon/[email protected]

07 Apr 14:42
Compare
Choose a tag to compare

@himenon/[email protected]

07 Apr 07:45
Compare
Choose a tag to compare
  • Add allowOperationIds option #40

@himenon/[email protected]

06 Apr 16:54
Compare
Choose a tag to compare

BREAKING_CHANGE

Deprecated API

  • generateTypeScriptCode

New API

  • CodeGenerator Class

Features

  • Code Generator's API has been classed to allow procedural code generation #31
  • Multiple code templates can be set in the generator #34
  • Enables direct retrieval of parameters extracted from OpenAPI #35
  • Code Template also accepts string in addition to the return value of ts.statement[].

Migration

Basic usage

Before

import { generateTypeScriptCode } from "@himenon/openapi-typescript-code-generator";

const code = generateTypeScriptCode({
  entryPoint,
  log: {
    validator: {
      displayLogLines: 1,
    },
  },
});

After

import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
import type * as Types from "@himenon/openapi-typescript-code-generator/types";

const codeGenerator = new CodeGenerator(entryPoint);

codeGenerator.validateOpenApiSchema({ logger: { displayLogLines: 1 } });

const apiClientGeneratorTemplate: Types.CodeGenerator.CustomGenerator<Templates.ApiClient.Option> = {
  generator: Templates.ApiClient.generator,
  option: {},
};

const code = codeGenerator.generateTypeDefinition([
  codeGenerator.getAdditionalTypeDefinitionCustomCodeGenerator(),
  apiClientGeneratorTemplate,
]);

For rewriteCodeAfterTypeDeclaration user

Before

import { generateTypeScriptCode } from "@himenon/openapi-typescript-code-generator";

const code = generateTypeScriptCode({
  entryPoint,
  option: {
    rewriteCodeAfterTypeDeclaration: (context, codeGeneratorParamsList) => {
      /** awesome code */
      return [];
    },
  },
});

After

import { CodeGenerator } from "@himenon/openapi-typescript-code-generator";
import * as Templates from "@himenon/openapi-typescript-code-generator/templates";
import type * as Types from "@himenon/openapi-typescript-code-generator/types";

const codeGenerator = new CodeGenerator(entryPoint);

const apiClientGeneratorTemplate: Types.CodeGenerator.CustomGenerator<Templates.ApiClient.Option> = {
  generator: Templates.ApiClient.generator,
  option: {},
};

const code = codeGenerator.generateTypeDefinition([
  codeGenerator.getAdditionalTypeDefinitionCustomCodeGenerator(),
  apiClientGeneratorTemplate,
  {
    generator: () => {
      /** awesome code */  // <------------ here!
      return [];
    },
  }
]);

@himenon/[email protected]

04 Apr 08:48
Compare
Choose a tag to compare

Features

  • Support dual package #27

@himenon/[email protected]

01 Apr 15:19
Compare
Choose a tag to compare

@himenon/[email protected]

23 Mar 12:26
Compare
Choose a tag to compare
  • Added an option to output API Client with synchronous functions #22

@himenon/[email protected]

22 Mar 15:24
Compare
Choose a tag to compare

New Features

  • Add allowOperationIds option.
  • Add ErrorResponse Type Declaration.