forked from loafle/openapi-generator-original
Javascript Generator: two small sanitization changes 🦠 (#13268)
* Javascript Generator: small sanitization changes Sanitize module name, do not sanitize description. If we set the project name to "@myorg/mypackage" (scoped package[1]), running `npm test` will fail, as it will generate faulty code due to the module name including the '@' symbol, which is not a valid JS identifier. Additionally, we don't need to sanitize the description - spaces and special characters are fine. We just need to make sure they are escaped, which we're already doing by invoking escapeText() on line 329 [1]anitize module name, do not sanitize description * update JS samples
This commit is contained in:
parent
b9a6be0cba
commit
1a5d3926b3
@ -296,7 +296,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
if (StringUtils.isEmpty(info.getDescription())) {
|
||||
projectDescription = "JS API client generated by OpenAPI Generator";
|
||||
} else {
|
||||
projectDescription = sanitizeName(info.getDescription());
|
||||
projectDescription = info.getDescription();
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
projectName = "openapi-js-client";
|
||||
}
|
||||
if (StringUtils.isBlank(moduleName)) {
|
||||
moduleName = camelize(underscore(projectName));
|
||||
moduleName = camelize(underscore(sanitizeName(projectName)));
|
||||
}
|
||||
if (StringUtils.isBlank(projectVersion)) {
|
||||
projectVersion = "1.0.0";
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "open_api_petstore",
|
||||
"version": "1.0.0",
|
||||
"description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters___",
|
||||
"description": "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\",
|
||||
"license": "Apache-2.0",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
|
@ -69,7 +69,7 @@ import UserApi from './api/UserApi';
|
||||
|
||||
|
||||
/**
|
||||
* This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters___.<br>
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\.<br>
|
||||
* The <code>index</code> module provides access to constructors for all the classes which comprise the public API.
|
||||
* <p>
|
||||
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "open_api_petstore",
|
||||
"version": "1.0.0",
|
||||
"description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters___",
|
||||
"description": "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\",
|
||||
"license": "Apache-2.0",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
|
@ -69,7 +69,7 @@ import UserApi from './api/UserApi';
|
||||
|
||||
|
||||
/**
|
||||
* This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters___.<br>
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\.<br>
|
||||
* The <code>index</code> module provides access to constructors for all the classes which comprise the public API.
|
||||
* <p>
|
||||
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
|
||||
|
Loading…
x
Reference in New Issue
Block a user