Skip to content

Commit 51f1785

Browse files
committed
update codegen to write output sorted, for now simply ignore the output
1 parent 74c0eff commit 51f1785

File tree

12 files changed

+119
-79
lines changed

12 files changed

+119
-79
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ node_modules
3838

3939
# Build output directory
4040
dist/
41-
41+
flight-recorder-generator/output

flight-recorder-generator/flight-recorder-json-generator.js

Lines changed: 19 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flight-recorder-generator/flight-recorder-json-generator.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {Specification} from "../specification/src/api-specification";
22
import * as fs from "fs";
33
import * as path from "path";
44
import * as Domain from "elasticsearch-client-specification/src/domain";
5+
import stringify from 'json-stable-stringify'
56

67
export class FlightRecorderJsonGenerator {
78
constructor(private specification: Specification) { }
@@ -21,7 +22,7 @@ export class FlightRecorderJsonGenerator {
2122
api: api.name,
2223
args
2324
};
24-
fs.writeFileSync(pathPrefix + "_request.json", JSON.stringify(request, null, 2));
25+
fs.writeFileSync(pathPrefix + "_request.json", stringify(request, {space:2}));
2526
const response = {
2627
api: api.name,
2728
headers: {},
@@ -31,7 +32,7 @@ export class FlightRecorderJsonGenerator {
3132
},
3233
statusCode: [200]
3334
};
34-
fs.writeFileSync(pathPrefix + "_response.json", JSON.stringify(response, null, 2));
35+
fs.writeFileSync(pathPrefix + "_response.json", stringify(response, {space:2}));
3536
});
3637

3738
}
@@ -64,13 +65,15 @@ export class FlightRecorderJsonGenerator {
6465
case "TResult" : return "__value__";
6566
case "string" :
6667
case "boolean" :
68+
return typeName;
6769
case "short" :
6870
case "byte" :
6971
case "integer" :
7072
case "long" :
73+
return "number";
7174
case "float" :
7275
case "double" :
73-
return typeName;
76+
return "number";
7477
case "object" :
7578
return {}
7679
}

flight-recorder-generator/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flight-recorder-generator/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
},
2020
"dependencies": {
2121
"elasticsearch-client-specification": "file:../specification",
22-
"lodash": "^4.17.15"
22+
"lodash": "^4.17.15",
23+
"json-stable-stringify": "^1.0.1"
2324
}
2425
}

flight-recorder-generator/tsconfig.json

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
{
2-
"compilerOptions": {
3-
"target": "es6",
4-
"module": "commonjs",
5-
"moduleResolution": "node",
6-
"isolatedModules": false,
7-
"jsx": "react",
8-
"experimentalDecorators": true,
9-
"emitDecoratorMetadata": true,
10-
"declaration": true,
11-
"noImplicitAny": false,
12-
"removeComments": true,
13-
"noLib": false,
14-
"preserveConstEnums": true,
15-
"sourceMap": true,
16-
"suppressImplicitAnyIndexErrors": true
17-
},
18-
"compileOnSave": true,
19-
"buildOnSave": true,
20-
"include": ["*.ts"],
2+
"compilerOptions": {
3+
"target": "es6",
4+
"module": "commonjs",
5+
"esModuleInterop": true,
6+
"moduleResolution": "node",
7+
"isolatedModules": false,
8+
"jsx": "react",
9+
"experimentalDecorators": true,
10+
"emitDecoratorMetadata": true,
11+
"declaration": true,
12+
"noImplicitAny": false,
13+
"removeComments": true,
14+
"noLib": false,
15+
"preserveConstEnums": true,
16+
"sourceMap": true,
17+
"suppressImplicitAnyIndexErrors": true
18+
},
19+
"compileOnSave": true,
20+
"buildOnSave": true,
21+
"include": [
22+
"*.ts"
23+
],
2124
"typeAcquisition": {
2225
"enable": true
2326
}

specification/src/api-specification.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import Domain = require("./domain");
22
import {SpecValidator} from "./specification/validator";
33
import {TypeReader} from "./specification/type-reader";
44
import {RestSpecMapping} from "./specification/rest-spec-mapping";
5-
import * as _ from "lodash";
5+
import _ from "lodash";
66
import * as glob from "glob";
7-
import * as ts from 'byots'
7+
import * as ts from "byots";
88

99
export type TypeDictionary = { [p: string]: Domain.TypeDeclaration };
1010
export class Specification {

specification/src/domain.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {RestSpecMapping} from "./specification/rest-spec-mapping";
2-
import * as _ from "lodash";
3-
import * as ts from 'byots'
2+
import _ from "lodash";
43

54
namespace Domain {
65

specification/src/specification/type-reader.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { RestSpecMapping } from "./rest-spec-mapping";
22
import Domain = require("../domain");
3-
import * as ts from 'byots';
3+
import * as ts from "byots";
44
export declare class TypeReader {
55
private program;
66
private checker;

specification/src/specification/type-reader.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { TypeName, RestSpecName, RestSpecMapping } from "./rest-spec-mapping";
22
import Domain = require("../domain");
3-
import * as _ from "lodash";
4-
import * as ts from 'byots'
3+
import _ from "lodash";
4+
import * as ts from "byots";
55

66
class Visitor {
77
constructor(protected checker: ts.TypeChecker) {}
88
protected symbolName = (node: ts.Node): string => this.checker.getSymbolAtLocation(node).getName();
99
}
1010

1111
class EnumVisitor extends Visitor {
12-
constructor(private enumNode: ts.EnumDeclaration, checker: ts.TypeChecker) {super(checker)}
12+
constructor(private enumNode: ts.EnumDeclaration, checker: ts.TypeChecker) {super(checker); }
1313

1414
visit(): Domain.Enum {
1515
const name = this.symbolName(this.enumNode.name);
@@ -123,7 +123,7 @@ class InterfaceVisitor extends Visitor {
123123
}
124124

125125
private createUnion(t: ts.TypeReferenceNode, typeName) {
126-
const args: ts.Node[] = t.typeArguments.map(n=>n as ts.Node);
126+
const args: ts.Node[] = t.typeArguments.map(n => n as ts.Node);
127127
const types = args.map(ct => this.visitTypeNode(ct));
128128
if (types.length < 2)
129129
throw Error("A union should have at least two types but saw " + types.length + " on " + typeName);
@@ -133,7 +133,7 @@ class InterfaceVisitor extends Visitor {
133133
}
134134

135135
private createDictionary(t: ts.TypeReferenceNode, typeName) {
136-
const args: ts.Node[] = t.typeArguments.map(n=>n as ts.Node);
136+
const args: ts.Node[] = t.typeArguments.map(n => n as ts.Node);
137137
const types = args.map(ct => this.visitTypeNode(ct));
138138
if (types.length !== 2)
139139
throw Error("A dictionary should contain 2 type args but found " + types.length + " on " + typeName);

specification/tsconfig.json

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
{
2-
"compilerOptions": {
3-
"target": "es6",
4-
"module": "commonjs",
5-
"moduleResolution": "node",
6-
"isolatedModules": false,
7-
"jsx": "react",
8-
"experimentalDecorators": true,
9-
"emitDecoratorMetadata": true,
10-
"declaration": true,
11-
"noImplicitAny": false,
12-
"removeComments": true,
13-
"noLib": false,
14-
"preserveConstEnums": true,
15-
"sourceMap": true,
16-
"suppressImplicitAnyIndexErrors": true
17-
},
18-
"compileOnSave": true,
19-
"buildOnSave": true,
20-
"include": ["src/**.ts"]
2+
"compilerOptions": {
3+
"target": "es6",
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"esModuleInterop": true,
7+
"isolatedModules": false,
8+
"jsx": "react",
9+
"experimentalDecorators": true,
10+
"emitDecoratorMetadata": true,
11+
"declaration": true,
12+
"noImplicitAny": false,
13+
"removeComments": true,
14+
"noLib": false,
15+
"preserveConstEnums": true,
16+
"sourceMap": true,
17+
"suppressImplicitAnyIndexErrors": true
18+
},
19+
"compileOnSave": true,
20+
"buildOnSave": true,
21+
"include": [
22+
"src/**.ts"
23+
]
2124
}

swagger-generator/tsconfig.json

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
{
2-
"compilerOptions": {
3-
"target": "es6",
4-
"module": "commonjs",
5-
"moduleResolution": "node",
6-
"isolatedModules": false,
7-
"jsx": "react",
8-
"experimentalDecorators": true,
9-
"emitDecoratorMetadata": true,
10-
"declaration": true,
11-
"noImplicitAny": false,
12-
"removeComments": true,
13-
"noLib": false,
14-
"preserveConstEnums": true,
15-
"sourceMap": true,
16-
"suppressImplicitAnyIndexErrors": true
17-
},
18-
"compileOnSave": true,
19-
"buildOnSave": true,
20-
"include": ["src/**.ts"],
21-
"typeAcquisition": {"enable": true }
2+
"compilerOptions": {
3+
"target": "es6",
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"esModuleInterop": true,
7+
"isolatedModules": false,
8+
"jsx": "react",
9+
"experimentalDecorators": true,
10+
"emitDecoratorMetadata": true,
11+
"declaration": true,
12+
"noImplicitAny": false,
13+
"removeComments": true,
14+
"noLib": false,
15+
"preserveConstEnums": true,
16+
"sourceMap": true,
17+
"suppressImplicitAnyIndexErrors": true
18+
},
19+
"compileOnSave": true,
20+
"buildOnSave": true,
21+
"include": [
22+
"src/**.ts"
23+
],
24+
"typeAcquisition": {
25+
"enable": true
26+
}
2227
}

0 commit comments

Comments
 (0)