Skip to content
Discussion options

You must be logged in to vote

Yes, this is the kind of customization I would do with a hook, not by post-processing generated files.

In current swagger-typescript-api, route names can be changed with hooks.onCreateRouteName or hooks.onFormatRouteName. For your case, onCreateRouteName is the clearest because it receives the final route name info and the raw route info.

Example config idea:

import { generateApi } from 'swagger-typescript-api'

const stripControllerPrefix = (name: string) =>
  name.replace(/^[A-Za-z0-9]+Controller_?/i, '')

await generateApi({
  input: './openapi.json',
  output: './src/api',
  modular: true,
  httpClientType: 'axios',
  hooks: {
    onCreateRouteName(routeNameInfo, rawRouteInfo) {
      r…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@gravitonlab
Comment options

Answer selected by gravitonlab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants