Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !5431
An error occurred while fetching the assigned milestone of the selected merge_request.

Base path name

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/topce/base-path-name into master 5 years ago
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 187

Created by: topce

add new option in cli to set different const name for BASE_PATH for angular-typescript client default value is BASE_PATH to pass another base path name use option -p basePathName=MY_BASE_PATH export const MY_BASE_PATH = new InjectionToken<string>('myBasePath'); instead of export const BASE_PATH = new InjectionToken<string>('basePath');

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @nicokoenig @topce @akehir @petejohansonxo @amakhrov

Compare
  • master (base)

and
  • latest version
    59bdf44b
    2 commits, 2 years ago

187 files
+ 4279
- 4263

    Preferences

    File browser
    Compare changes
modules/openap‎i-generator/src‎
ma‎in‎
java/org/openapitoo‎ls/codegen/languages‎
TypeScriptAngular‎ClientCodegen.java‎ +17 -2
resources/type‎script-angular‎
api.servic‎e.mustache‎ +2 -2
variables‎.mustache‎ +1 -1
test/java/org/…‎/codegen/options‎
TypeScriptAngularClie‎ntOptionsProvider.java‎ +2 -1
samples/cli‎ent/petstore‎
typescript‎-angular-v2‎
def‎ault‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +176 -176
inde‎x.ts‎ +4 -4
rxjs-ope‎rators.ts‎ +11 -11
n‎pm‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +176 -176
inde‎x.ts‎ +4 -4
rxjs-ope‎rators.ts‎ +11 -11
tsconf‎ig.json‎ +32 -32
with-in‎terfaces‎
a‎pi‎
api‎.ts‎ +10 -10
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +176 -176
inde‎x.ts‎ +4 -4
rxjs-ope‎rators.ts‎ +11 -11
typescript-an‎gular-v4.3/npm‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +180 -180
inde‎x.ts‎ +4 -4
ng-pack‎age.json‎ +6 -6
tsconf‎ig.json‎ +28 -28
typescript-a‎ngular-v4/npm‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +176 -176
inde‎x.ts‎ +4 -4
ng-pack‎age.json‎ +6 -6
rxjs-ope‎rators.ts‎ +11 -11
tsconf‎ig.json‎ +28 -28
…‎/…‎
def‎ault‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +180 -180
inde‎x.ts‎ +4 -4
with‎-npm‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +180 -180
inde‎x.ts‎ +4 -4
ng-pack‎age.json‎ +6 -6
tsconf‎ig.json‎ +28 -28
…‎/…‎
def‎ault‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +180 -180
inde‎x.ts‎ +4 -4
with‎-npm‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +180 -180
inde‎x.ts‎ +4 -4
ng-pack‎age.json‎ +6 -6
tsconf‎ig.json‎ +28 -28
…‎/…‎
def‎ault‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +180 -180
inde‎x.ts‎ +4 -4
with‎-npm‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +180 -180
inde‎x.ts‎ +4 -4
ng-pack‎age.json‎ +6 -6
tsconf‎ig.json‎ +28 -28
…‎/…‎
def‎ault‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +180 -180
inde‎x.ts‎ +4 -4
with‎-npm‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +180 -180
inde‎x.ts‎ +4 -4
ng-pack‎age.json‎ +6 -6
tsconf‎ig.json‎ +28 -28
…‎/…‎
single-reque‎st-parameter‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +180 -180
inde‎x.ts‎ +4 -4
ng-pack‎age.json‎ +6 -6
tsconf‎ig.json‎ +28 -28
with‎-npm‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +180 -180
inde‎x.ts‎ +4 -4
ng-pack‎age.json‎ +6 -6
tsconf‎ig.json‎ +28 -28
with-prefixe‎d-module-name‎
a‎pi‎
api‎.ts‎ +7 -7
mo‎del‎
apiResp‎onse.ts‎ +5 -5
categ‎ory.ts‎ +4 -4
orde‎r.ts‎ +11 -11
pet‎.ts‎ +11 -11
tag‎.ts‎ +4 -4
use‎r.ts‎ +13 -13
.giti‎gnore‎ +4 -4
READ‎ME.md‎ +180 -180
inde‎x.ts‎ +4 -4
ng-pack‎age.json‎ +6 -6
tsconf‎ig.json‎ +28 -28
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
+ 17
- 2
  • View file @ 59bdf44b


@@ -17,6 +17,8 @@
package org.openapitools.codegen.languages;
import com.google.common.base.CaseFormat;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.DocumentationFeature;
@@ -55,18 +57,21 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
public static final String FILE_NAMING = "fileNaming";
public static final String STRING_ENUMS = "stringEnums";
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
public static final String BASE_PATH_NAME = "basePathName";
public static final String BASE_PATH_NAME_CAMEL_CASE = "basePathNameCamelCase";
protected String ngVersion = "9.0.0";
protected String npmRepository = null;
private boolean useSingleRequestParameter = false;
protected String serviceSuffix = "Service";
protected String serviceFileSuffix = ".service";
protected String modelSuffix = "";
protected String modelFileSuffix = "";
protected String fileNaming = "camelCase";
protected Boolean stringEnums = false;
protected String basePathName = "BASE_PATH";
private boolean taggedUnions = false;
private boolean useSingleRequestParameter = false;
public TypeScriptAngularClientCodegen() {
super();
@@ -109,6 +114,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
this.cliOptions.add(new CliOption(MODEL_FILE_SUFFIX, "The suffix of the file of the generated model (model<suffix>.ts)."));
this.cliOptions.add(new CliOption(FILE_NAMING, "Naming convention for the output files: 'camelCase', 'kebab-case'.").defaultValue(this.fileNaming));
this.cliOptions.add(new CliOption(STRING_ENUMS, STRING_ENUMS_DESC).defaultValue(String.valueOf(this.stringEnums)));
this.cliOptions.add(new CliOption(BASE_PATH_NAME, "The base path name.").defaultValue(this.basePathName));
}
@Override
@@ -234,10 +240,19 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
if (additionalProperties.containsKey(FILE_NAMING)) {
this.setFileNaming(additionalProperties.get(FILE_NAMING).toString());
}
if (isEnumSuffixV4Compat) {
applyEnumSuffixV4CompatMode();
}
if (additionalProperties.containsKey(BASE_PATH_NAME)) {
String value = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, additionalProperties.get(BASE_PATH_NAME).toString());
additionalProperties.put(BASE_PATH_NAME_CAMEL_CASE,value);
} else{
additionalProperties.put(BASE_PATH_NAME, this.basePathName);
String value = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, additionalProperties.get(BASE_PATH_NAME).toString());
additionalProperties.put(BASE_PATH_NAME_CAMEL_CASE,value);
}
}
private void applyEnumSuffixV4CompatMode() {
modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache
+ 2
- 2
  • View file @ 59bdf44b


@@ -27,7 +27,7 @@ import '../rxjs-operators';
import { {{classname}} } from '../model/models';
{{/imports}}
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { {{basePathName}}, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
{{#withInterfaces}}
import {
@@ -84,7 +84,7 @@ export class {{classname}} {
public encoder: QueryEncoder;
{{/useHttpClient}}
constructor(protected {{#useHttpClient}}httpClient: HttpClient{{/useHttpClient}}{{^useHttpClient}}http: Http{{/useHttpClient}}, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
constructor(protected {{#useHttpClient}}httpClient: HttpClient{{/useHttpClient}}{{^useHttpClient}}http: Http{{/useHttpClient}}, @Optional()@Inject({{basePathName}}) basePath: string, @Optional() configuration: Configuration) {
if (configuration) {
this.configuration = configuration;
}
modules/openapi-generator/src/main/resources/typescript-angular/variables.mustache
+ 1
- 1
  • View file @ 59bdf44b


import { {{injectionToken}} } from '@angular/core';
export const BASE_PATH = new {{injectionToken}}{{#injectionTokenTyped}}<string>{{/injectionTokenTyped}}('basePath');
export const {{basePathName}} = new {{injectionToken}}{{#injectionTokenTyped}}<string>{{/injectionTokenTyped}}('{{basePathNameCamelCase}}');
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',
modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptAngularClientOptionsProvider.java
+ 2
- 1
  • View file @ 59bdf44b


@@ -46,7 +46,7 @@ public class TypeScriptAngularClientOptionsProvider implements OptionsProvider {
public static String SERVICE_FILE_SUFFIX = ".service";
public static String MODEL_SUFFIX = "";
public static String MODEL_FILE_SUFFIX = "";
public static String BASE_PATH_NAME = "BASE_PATH";
@Override
public String getLanguage() {
return "typescript-angular";
@@ -81,6 +81,7 @@ public class TypeScriptAngularClientOptionsProvider implements OptionsProvider {
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
.put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE)
.put(TypeScriptAngularClientCodegen.FILE_NAMING, FILE_NAMING_VALUE)
.put(TypeScriptAngularClientCodegen.BASE_PATH_NAME, BASE_PATH_NAME )
.build();
}
samples/client/petstore/typescript-angular-v2/default/api/api.ts
+ 7
- 7
  • View file @ 59bdf44b

export * from './pet.service';
import { PetService } from './pet.service';
export * from './store.service';
import { StoreService } from './store.service';
export * from './user.service';
import { UserService } from './user.service';
export const APIS = [PetService, StoreService, UserService];
export * from './pet.service';
import { PetService } from './pet.service';
export * from './store.service';
import { StoreService } from './store.service';
export * from './user.service';
import { UserService } from './user.service';
export const APIS = [PetService, StoreService, UserService];
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: github/fork/topce/base-path-name

Menu

Explore Projects Groups Snippets