Skip to content

Commit 57e52f4

Browse files
committed
fix: open API generator config - protected keyword
This changes makes it so that model properties named `protected` will no longer get mangled by the OpenAPI generator into `_protected`. This is needed so that our generated models can be compliant with the JWS RFC [1] Since `protected` is only a softly reserved keyword, this means that you can still declare classes/interfaces with fields that are called `protected` which is what we need since the RFC mentioned above declares exactly that for JWS recipients. [1]: https://tools.ietf.org/html/rfc7515 Fixes hyperledger-cacti#436 Signed-off-by: Peter Somogyvari <[email protected]>
1 parent a78b18d commit 57e52f4

File tree

9 files changed

+8
-11
lines changed

9 files changed

+8
-11
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"start:example-supply-chain": "node ./examples/supply-chain-app/node_modules/.bin/cactus-example-supply-chain-backend",
1111
"export-open-api-spec": "ts-node -e 'import(\"./packages/cactus-cmd-api-server/src/main/typescript/openapi-spec\").then((x) => x.exportToFileSystemAsJson());'",
1212
"pregenerate-sdk": "npm-run-all export-open-api-spec",
13-
"generate-sdk": "openapi-generator generate --input-spec cactus-openapi-spec.json -g typescript-axios -o packages/cactus-api-client/src/main/typescript/generated/openapi/typescript-axios/",
13+
"generate-sdk": "openapi-generator generate --input-spec cactus-openapi-spec.json -g typescript-axios -o packages/cactus-api-client/src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected",
1414
"clean": "lerna exec --stream --ignore '*/*cockpit' -- del-cli dist/** && del-cli packages/cactus-api-client/src/main/typescript/generated/openapi/typescript-axios/*",
1515
"lint": "lerna exec --stream --ignore '*/*cockpit' -- cross-env DEBUG= tslint --project tsconfig.json",
1616
"tsc": "lerna run tsc",

packages/cactus-core-api/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"scripts": {
1515
"export-open-api-spec": "ts-node src/main/typescript/openapi-spec.ts",
1616
"pregenerate-sdk": "npm-run-all export-open-api-spec",
17-
"generate-sdk": "openapi-generator generate --input-spec src/main/json/generated/openapi-spec.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/",
17+
"generate-sdk": "openapi-generator generate --input-spec src/main/json/generated/openapi-spec.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected",
1818
"pretsc": "npm run generate-sdk",
1919
"tsc": "tsc --project ./tsconfig.json",
2020
"webpack": "npm-run-all webpack:dev webpack:prod",

packages/cactus-core-api/src/main/typescript/generated/openapi/typescript-axios/api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export interface JWSRecipient {
253253
* @type {string}
254254
* @memberof JWSRecipient
255255
*/
256-
_protected?: string;
256+
protected?: string;
257257
/**
258258
*
259259
* @type {{ [key: string]: object; }}

packages/cactus-core-api/src/main/typescript/openapi-spec.ts

-3
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,6 @@ export const CACTUS_OPEN_API_JSON: OpenAPIV3.Document = {
371371
signature: {
372372
type: "string",
373373
},
374-
// In the generated models this shows up as _protected because it is
375-
// a reserved keyword in Typescript. Opened an issue here about this:
376-
// https://github.com/OpenAPITools/openapi-generator/issues/7100
377374
protected: {
378375
type: "string",
379376
},

packages/cactus-plugin-consortium-manual/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"scripts": {
1515
"export-open-api-spec": "ts-node src/main/typescript/openapi-spec.ts",
1616
"pregenerate-sdk": "npm-run-all export-open-api-spec",
17-
"generate-sdk": "openapi-generator generate --input-spec src/main/json/generated/openapi-spec.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/",
17+
"generate-sdk": "openapi-generator generate --input-spec src/main/json/generated/openapi-spec.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected",
1818
"tsc": "tsc --project ./tsconfig.json",
1919
"pretsc": "npm run generate-sdk",
2020
"webpack": "npm-run-all webpack:dev webpack:prod",

packages/cactus-plugin-consortium-manual/src/main/typescript/generated/openapi/typescript-axios/api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export interface JWSRecipient {
8181
* @type {string}
8282
* @memberof JWSRecipient
8383
*/
84-
_protected?: string;
84+
protected?: string;
8585
/**
8686
*
8787
* @type {{ [key: string]: object; }}

packages/cactus-plugin-ledger-connector-besu/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"scripts": {
1515
"export-open-api-spec": "ts-node src/main/typescript/openapi-spec.ts",
1616
"pregenerate-sdk": "npm-run-all export-open-api-spec",
17-
"generate-sdk": "openapi-generator generate --input-spec src/main/json/generated/openapi-spec.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/",
17+
"generate-sdk": "openapi-generator generate --input-spec src/main/json/generated/openapi-spec.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected",
1818
"pretsc": "npm run generate-sdk",
1919
"tsc": "tsc --project ./tsconfig.json",
2020
"webpack": "npm-run-all webpack:dev webpack:prod",

packages/cactus-plugin-ledger-connector-fabric/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"scripts": {
1515
"export-open-api-spec": "ts-node -e 'import(\"./src/main/typescript/openapi-spec\").then((x) => x.exportToFileSystemAsJson());'",
1616
"pregenerate-sdk": "npm-run-all export-open-api-spec",
17-
"generate-sdk": "openapi-generator generate --input-spec src/main/json/generated/openapi-spec.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/",
17+
"generate-sdk": "openapi-generator generate --input-spec src/main/json/generated/openapi-spec.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected",
1818
"pretsc": "npm run generate-sdk",
1919
"tsc": "tsc --project ./tsconfig.json",
2020
"webpack": "npm-run-all webpack:dev webpack:prod",

packages/cactus-plugin-ledger-connector-quorum/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"scripts": {
1515
"export-open-api-spec": "ts-node ./src/main/typescript/openapi-spec.ts",
1616
"pregenerate-sdk": "npm-run-all export-open-api-spec",
17-
"generate-sdk": "openapi-generator generate --input-spec cactus-openapi-spec-plugin-ledger-connector-quorum.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/",
17+
"generate-sdk": "openapi-generator generate --input-spec cactus-openapi-spec-plugin-ledger-connector-quorum.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected",
1818
"pretsc": "npm run generate-sdk",
1919
"tsc": "tsc --project ./tsconfig.json",
2020
"webpack": "npm-run-all webpack:dev webpack:prod",

0 commit comments

Comments
 (0)