acacode / swagger-typescript-api

Generate the API Client for Fetch or Axios from an OpenAPI Specification
MIT License
3.27k stars 354 forks source link

Feature request: 'interfacePrefix' #466

Open inomn opened 1 year ago

inomn commented 1 year ago

Hi! First of all thanks for this project!

Currently, there are several props for prefix\suffix settings:

typePrefix: '',
typeSuffix: '',
enumKeyPrefix: '',
enumKeySuffix: '',

But the one is missing is interfacePrefix (and interfaceSuffix).

Ideally, I want to have a "T" prefix for my types, and "I" for my interfaces, as far as I understand, currently it's impossible, and typePrefix will be applied to both types and interfaces.

Thanks!

chiralium commented 1 year ago

I'm trying override the ETA-templates but it has no effects. For example in type inheritance

inomn commented 1 year ago

hi @js2me, what do you think about it?

whosdustin commented 1 year ago

I'm trying override the ETA-templates but it has no effects. For example in type inheritance

@chiralium The template to override is data-contracts.ejs

const dataContractTemplates = {
  enum: (contract) => {
    return `enum ${contract.name} {\r\n${contract.content} \r\n }`;
  },
  interface: (contract) => {
    /**
     * Add your prefix/suffix here
     */
    return `interface I${contract.name} {\r\n${contract.content}}`;
  },
  type: (contract) => {
    return `type ${contract.name} = ${contract.content}`;
  },
}
chiralium commented 1 year ago

I'm trying override the ETA-templates but it has no effects. For example in type inheritance

@chiralium The template to override is data-contracts.ejs

const dataContractTemplates = {
  enum: (contract) => {
    return `enum ${contract.name} {\r\n${contract.content} \r\n }`;
  },
  interface: (contract) => {
    /**
     * Add your prefix/suffix here
     */
    return `interface I${contract.name} {\r\n${contract.content}}`;
  },
  type: (contract) => {
    return `type ${contract.name} = ${contract.content}`;
  },
}

This template override the interface definition, but not the extends part where super-interface has no prefix

conexyit commented 6 months ago

any news?