Skip to content

[TypeScript Client] fix install Aurelia, fix use deprecated function #2514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/utils/ensure-up-to-date
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ declare -a scripts=(
"./bin/php-ze-ph-petstore-server.sh"
"./bin/openapi3/php-petstore.sh"
"./bin/typescript-angular-petstore-all.sh"
"./bin/typescript-aurelia-petstore.sh"
"./bin/typescript-axios-petstore-all.sh"
"./bin/typescript-fetch-petstore-all.sh"
"./bin/typescript-node-petstore-all.sh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.SemVer;
import org.openapitools.codegen.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -512,7 +513,7 @@ public String toApiName(String name) {
if (name.length() == 0) {
return "DefaultService";
}
return initialCaps(name) + serviceSuffix;
return StringUtils.camelize(name) + serviceSuffix;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll file a PR to deprecate initialCaps before the 4.x release.

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.openapitools.codegen.languages;

import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.StringUtils;

import java.util.*;

Expand Down Expand Up @@ -104,7 +105,7 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
// Aurelia uses "asGet", "asPost", ... methods; change the method format
op.httpMethod = initialCaps(op.httpMethod.toLowerCase(Locale.ROOT));
op.httpMethod = StringUtils.camelize(op.httpMethod.toLowerCase(Locale.ROOT));

// Collect models to be imported
for (CodegenParameter param : op.allParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.StringUtils;

import java.io.File;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -321,7 +322,7 @@ public String toApiName(String name) {
if (name.length() == 0) {
return "DefaultService";
}
return initialCaps(name) + "Service";
return StringUtils.camelize(name) + "Service";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -98,7 +99,7 @@ public String toApiName(String name) {
if (name.length() == 0) {
return "Default" + apiSuffix;
}
return initialCaps(name) + apiSuffix;
return StringUtils.camelize(name) + apiSuffix;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ Module system

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))

### Installation ###
### Building ####

`openapi-generator` does not generate JavaScript directly. The generated Node module comes with `package.json` that bundles `typescript` and `typings` so it can self-compile during `prepublish` stage. The should be run automatically during `npm install` or `npm publish`.

CAVEAT: Due to [privilege implications](https://docs.npmjs.com/misc/scripts#user), `npm` would skip all scripts if the user is `root`. You would need to manually run it with `npm run prepublish` or run `npm install --unsafe-perm`.
To build and compile the typescript sources to javascript use:
```
npm install
npm run build
```

#### NPM ####
You may publish the module to NPM. In this case, you would be able to install the module as any other NPM module. It maybe useful to use [scoped packages](https://docs.npmjs.com/misc/scope).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{
"name": "{{#npmName}}{{{npmName}}}{{/npmName}}{{^npmName}}typescript-fetch-api{{/npmName}}",
"name": "{{#npmName}}{{{npmName}}}{{/npmName}}{{^npmName}}typescript-aurelia-api{{/npmName}}",
"version": "{{#npmVersion}}{{{npmVersion}}}{{/npmVersion}}{{^npmVersion}}0.0.0{{/npmVersion}}",
"license": "Unlicense",
"main": "./dist/api.js",
"browser": "./dist/api.js",
"typings": "./dist/api.d.ts",
"main": "./dist/Api.js",
"browser": "./dist/Api.js",
"typings": "./dist/Api.d.ts",
"dependencies": {
{{^supportsES6}}"core-js": "^2.4.0",
{{/supportsES6}}"isomorphic-fetch": "^2.2.1"
{{/supportsES6}}"isomorphic-fetch": "^2.2.1",
"aurelia-framework": "^1.3.1",
"aurelia-http-client": "^1.3.0"
},
"scripts" : {
"prepublish" : "typings install && tsc",
"test": "tslint api.ts"
"scripts": {
"build": "tsc --outDir dist/",
"prepare": "npm run build",
"test": "tslint Api.ts"
},
"devDependencies": {
"tslint": "^3.15.1",
"typescript": "^1.8.10",
"typings": "^1.0.4"
"typescript": "^2.4 || ^3.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
"noImplicitAny": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
"es6",
"dom"
],
"typeRoots": [
"node_modules/@types"
]
],
"experimentalDecorators": true
},
"exclude": [
"dist",
Expand Down
10 changes: 6 additions & 4 deletions samples/client/petstore/typescript-aurelia/default/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ Module system

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))

### Installation ###
### Building ####

`openapi-generator` does not generate JavaScript directly. The generated Node module comes with `package.json` that bundles `typescript` and `typings` so it can self-compile during `prepublish` stage. The should be run automatically during `npm install` or `npm publish`.

CAVEAT: Due to [privilege implications](https://docs.npmjs.com/misc/scripts#user), `npm` would skip all scripts if the user is `root`. You would need to manually run it with `npm run prepublish` or run `npm install --unsafe-perm`.
To build and compile the typescript sources to javascript use:
```
npm install
npm run build
```

#### NPM ####
You may publish the module to NPM. In this case, you would be able to install the module as any other NPM module. It maybe useful to use [scoped packages](https://docs.npmjs.com/misc/scope).
Expand Down
22 changes: 12 additions & 10 deletions samples/client/petstore/typescript-aurelia/default/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{
"name": "typescript-fetch-api",
"name": "typescript-aurelia-api",
"version": "0.0.0",
"license": "Unlicense",
"main": "./dist/api.js",
"browser": "./dist/api.js",
"typings": "./dist/api.d.ts",
"main": "./dist/Api.js",
"browser": "./dist/Api.js",
"typings": "./dist/Api.d.ts",
"dependencies": {
"core-js": "^2.4.0",
"isomorphic-fetch": "^2.2.1"
"isomorphic-fetch": "^2.2.1",
"aurelia-framework": "^1.3.1",
"aurelia-http-client": "^1.3.0"
},
"scripts" : {
"prepublish" : "typings install && tsc",
"test": "tslint api.ts"
"scripts": {
"build": "tsc --outDir dist/",
"prepare": "npm run build",
"test": "tslint Api.ts"
},
"devDependencies": {
"tslint": "^3.15.1",
"typescript": "^1.8.10",
"typings": "^1.0.4"
"typescript": "^2.4 || ^3.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
"module": "commonjs",
"noImplicitAny": true,
"outDir": "dist",
"rootDir": "."
"rootDir": ".",
"lib": [
"es6",
"dom"
],
"typeRoots": [
"node_modules/@types"
],
"experimentalDecorators": true
},
"exclude": [
"dist",
Expand Down