Skip to content

Commit e6b15b2

Browse files
committed
Adds a configuration parameter for the generated ContentType enum to avoid clashing
1 parent af0d79f commit e6b15b2

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/configuration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ export class CodeGenConfig {
180180

181181
successResponseStatusRange = [200, 299];
182182

183+
contentTypeEnumName = 'ContentType'
184+
183185
extractingOptions: Partial<ExtractingOptions> = {
184186
requestBodySuffix: ["Payload", "Body", "Input"],
185187
requestParamsSuffix: ["Params"],

templates/base/http-clients/fetch-http-client.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface HttpResponse<D extends unknown, E extends unknown = unknown> ex
4141

4242
type CancelToken = Symbol | string | number;
4343

44-
export enum ContentType {
44+
export enum <%~ config.contentTypeEnumName %> {
4545
Json = "application/json",
4646
JsonApi = "application/vnd.api+json",
4747
FormData = "multipart/form-data",

types/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,10 @@ export interface GenerateApiConfiguration {
674674
extractingOptions: Partial<ExtractingOptions>;
675675
/** update configuration object during generation */
676676
update: (update: Partial<GenerateApiConfiguration["config"]>) => void;
677+
/** name for the generated ContentType enum
678+
* @default ContentType
679+
*/
680+
contentTypeEnumName: string
677681
};
678682
modelTypes: ModelType[];
679683
hasFormDataRoutes: boolean;

0 commit comments

Comments
 (0)