swagger-api / swagger-api/swagger-codegen

Pascal case class name for request class

Open
#8,992 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I'm creating a custom Typescript template for Angular 7 app. I used existing template as starter. In the api.service.mustache I added:

{{#operations}}
	{{#operation}}
	export class {{nickname}}Request {
		{{#allParams}}{{^isConstEnumParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}; {{/isConstEnumParam}}
	{{/allParams}}
	}
	{{/operation}}
{{/operations}}

which results to

export class someClassNameRequest {
/////
}

I can not come up with the solution to make it pascal case like SomeClassNameRequest. Now I use {{nickname}} as a prefix but opened to use any other variable with a descriptive name. I tried to figure out how to see the whole object that is sent to the mustache template without any success.

Any suggestions are welcome.

Swagger-codegen version

2.3.1

Swagger declaration file content or url

looks like not related

Command line used for generation

rm -rf ./src/app/core/web-api; mkdir ./src/app/core/web-api; npx swagger-codegen generate -i ./swagger/swagger.yaml -l typescript-angular -o ./src/app/core/web-api -t ./swagger-codegen-typescript-angular

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the custom api.service.mustache template and the typescript-angular template resources, then run the provided swagger-codegen command against the example declaration. Check how nickname and other operation fields are exposed to templates and verify that the generated request class uses the desired PascalCase name.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.