Skip to content

Commit

Permalink
refactor: project-wide change of OAS vendor extensions cactus -> cacti
Browse files Browse the repository at this point in the history
1. Did a complete find & replace of the old vendor extensions and the
new ones. In theory this is a change that the compiler guarantees for us
to verify completely, but even with that said, I'll leave the CI on so
that we can double check to be sure.
This is also a BREAKING CHANGE because if someone had installed the older
packages and they imported endpoint definitions from the OAS spec based
on the vendor extensions then their could would stop compiling. Therefore
this change must be done before we issue the 2.0.0 release.
2. Also added a bug-fix to tools/custom-checks/check-open-api-json-specs.ts
because it wasn't just validating HTTP verbs within "paths" but also
any property that was in there such as "summary" or "description" but
of course those are string properties so they won't pass the validation
we impose on HTTP verb definitions for the endpoints.

Fixes hyperledger#2872

Signed-off-by: Peter Somogyvari <[email protected]>
  • Loading branch information
petermetz committed Nov 15, 2023
1 parent bf9dfe8 commit 31ac3f1
Show file tree
Hide file tree
Showing 149 changed files with 447 additions and 417 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"post": {
"operationId": "enrollAdminV1",
"summary": "Registers an admin account within the Fabric organization specified.",
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"authz": {
"isProtected": true,
"requiredRoles": ["group:admin"]
Expand Down Expand Up @@ -192,7 +192,7 @@
"post": {
"operationId": "daoTokenGetAllowanceV1",
"summary": "Get the number of tokens `spender` is approved to spend on behalf of `account`",
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-example-carbon-accounting-backend/dao-token/get-allowance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ export class GetAllowanceEndpoint implements IWebServiceEndpoint {
}

public getVerbLowerCase(): string {
return this.oasPath.post["x-hyperledger-cactus"].http.verbLowerCase;
return this.oasPath.post["x-hyperledger-cacti"].http.verbLowerCase;
}

public getPath(): string {
return this.oasPath.post["x-hyperledger-cactus"].http.path;
return this.oasPath.post["x-hyperledger-cacti"].http.path;
}

public getExpressRequestHandler(): IExpressRequestHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class EnrollAdminV1Endpoint implements IWebServiceEndpoint {

getAuthorizationOptionsProvider(): IAsyncProvider<IEndpointAuthzOptions> {
return {
get: async () => this.oasPath.post["x-hyperledger-cactus"].authz,
get: async () => this.oasPath.post["x-hyperledger-cacti"].authz,
};
}

Expand All @@ -57,11 +57,11 @@ export class EnrollAdminV1Endpoint implements IWebServiceEndpoint {
}

public getVerbLowerCase(): string {
return this.oasPath.post["x-hyperledger-cactus"].http.verbLowerCase;
return this.oasPath.post["x-hyperledger-cacti"].http.verbLowerCase;
}

public getPath(): string {
return this.oasPath.post["x-hyperledger-cactus"].http.path;
return this.oasPath.post["x-hyperledger-cacti"].http.path;
}

public getExpressRequestHandler(): IExpressRequestHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
"/api/v1/plugins/@hyperledger/cactus-example-supply-chain-backend/insert-bookshelf": {
"post": {
"operationId": "insertBookshelfV1",
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-example-supply-chain-backend/insert-bookshelf"
Expand Down Expand Up @@ -249,7 +249,7 @@
"/api/v1/plugins/@hyperledger/cactus-example-supply-chain-backend/list-bookshelf": {
"get": {
"operationId": "listBookshelfV1",
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "get",
"path": "/api/v1/plugins/@hyperledger/cactus-example-supply-chain-backend/list-bookshelf"
Expand All @@ -273,7 +273,7 @@
},
"/api/v1/plugins/@hyperledger/cactus-example-supply-chain-backend/insert-shipment": {
"post": {
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-example-supply-chain-backend/insert-shipment"
Expand Down Expand Up @@ -307,7 +307,7 @@
},
"/api/v1/plugins/@hyperledger/cactus-example-supply-chain-backend/list-shipment": {
"get": {
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "get",
"path": "/api/v1/plugins/@hyperledger/cactus-example-supply-chain-backend/list-shipment"
Expand All @@ -333,7 +333,7 @@
"/api/v1/plugins/@hyperledger/cactus-example-supply-chain-backend/insert-bamboo-harvest": {
"post": {
"operationId": "insertBambooHarvestV1",
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-example-supply-chain-backend/insert-bamboo-harvest"
Expand Down Expand Up @@ -367,7 +367,7 @@
"/api/v1/plugins/@hyperledger/cactus-example-supply-chain-backend/list-bamboo-harvest": {
"get": {
"operationId": "listBambooHarvestV1",
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "get",
"path": "/api/v1/plugins/@hyperledger/cactus-example-supply-chain-backend/list-bamboo-harvest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ export class InsertBambooHarvestEndpoint implements IWebServiceEndpoint {

public getVerbLowerCase(): string {
const apiPath = this.getOasPath();
return apiPath.post["x-hyperledger-cactus"].http.verbLowerCase;
return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase;
}

public getPath(): string {
const apiPath = this.getOasPath();
return apiPath.post["x-hyperledger-cactus"].http.path;
return apiPath.post["x-hyperledger-cacti"].http.path;
}

public getExpressRequestHandler(): IExpressRequestHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ export class InsertBookshelfEndpoint implements IWebServiceEndpoint {

public getVerbLowerCase(): string {
const apiPath = this.getOasPath();
return apiPath.post["x-hyperledger-cactus"].http.verbLowerCase;
return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase;
}

public getPath(): string {
const apiPath = this.getOasPath();
return apiPath.post["x-hyperledger-cactus"].http.path;
return apiPath.post["x-hyperledger-cacti"].http.path;
}

public getExpressRequestHandler(): IExpressRequestHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ export class InsertShipmentEndpoint implements IWebServiceEndpoint {

getPath(): string {
const apiPath = this.getOasPath();
return apiPath.post["x-hyperledger-cactus"].http.path;
return apiPath.post["x-hyperledger-cacti"].http.path;
}

getVerbLowerCase(): string {
const apiPath = this.getOasPath();
return apiPath.post["x-hyperledger-cactus"].http.verbLowerCase;
return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase;
}

public getOperationId(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ export class ListBambooHarvestEndpoint implements IWebServiceEndpoint {

public getVerbLowerCase(): string {
const apiPath = this.getOasPath();
return apiPath.get["x-hyperledger-cactus"].http.verbLowerCase;
return apiPath.get["x-hyperledger-cacti"].http.verbLowerCase;
}

public getPath(): string {
const apiPath = this.getOasPath();
return apiPath.get["x-hyperledger-cactus"].http.path;
return apiPath.get["x-hyperledger-cacti"].http.path;
}

public getExpressRequestHandler(): IExpressRequestHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ export class ListBookshelfEndpoint implements IWebServiceEndpoint {

public getVerbLowerCase(): string {
const apiPath = this.getOasPath();
return apiPath.get["x-hyperledger-cactus"].http.verbLowerCase;
return apiPath.get["x-hyperledger-cacti"].http.verbLowerCase;
}

public getPath(): string {
const apiPath = this.getOasPath();
return apiPath.get["x-hyperledger-cactus"].http.path;
return apiPath.get["x-hyperledger-cacti"].http.path;
}

public getExpressRequestHandler(): IExpressRequestHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export class ListShipmentEndpoint implements IWebServiceEndpoint {

getPath(): string {
const apiPath = this.getOasPath();
return apiPath.get["x-hyperledger-cactus"].http.path;
return apiPath.get["x-hyperledger-cacti"].http.path;
}

getVerbLowerCase(): string {
const apiPath = this.getOasPath();
return apiPath.get["x-hyperledger-cactus"].http.verbLowerCase;
return apiPath.get["x-hyperledger-cacti"].http.verbLowerCase;
}

public getOperationId(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
"paths": {
"/api/v1/plugins/@hyperledger/cactus-plugin-htlc-coordinator-besu/own-htlc": {
"post": {
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-htlc-coordinator-besu/own-htlc"
Expand Down Expand Up @@ -245,7 +245,7 @@
},
"/api/v1/plugins/@hyperledger/cactus-plugin-htlc-coordinator-besu/counterparty-htlc": {
"post": {
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-htlc-coordinator-besu/counterparty-htlc"
Expand Down Expand Up @@ -277,7 +277,7 @@
},
"/api/v1/plugins/@hyperledger/cactus-plugin-htlc-coordinator-besu/withdraw-counterparty": {
"post": {
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-htlc-coordinator-besu/withdraw-counterparty"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export class CounterpartyHTLCEndpoint implements IWebServiceEndpoint {

public getPath(): string {
const apiPath = this.getOasPath();
return apiPath.post["x-hyperledger-cactus"].http.path;
return apiPath.post["x-hyperledger-cacti"].http.path;
}

public getVerbLowerCase(): string {
const apiPath = this.getOasPath();
return apiPath.post["x-hyperledger-cactus"].http.verbLowerCase;
return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase;
}

public getOperationId(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export class OwnHTLCEndpoint implements IWebServiceEndpoint {

public getPath(): string {
const apiPath = this.getOasPath();
return apiPath.post["x-hyperledger-cactus"].http.path;
return apiPath.post["x-hyperledger-cacti"].http.path;
}

public getVerbLowerCase(): string {
const apiPath = this.getOasPath();
return apiPath.post["x-hyperledger-cactus"].http.verbLowerCase;
return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase;
}

public getOperationId(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ export class WithdrawCounterpartyEndpoint implements IWebServiceEndpoint {

public getPath(): string {
const apiPath = this.getOasPath();
return apiPath.post["x-hyperledger-cactus"].http.path;
return apiPath.post["x-hyperledger-cacti"].http.path;
}

public getVerbLowerCase(): string {
const apiPath = this.getOasPath();
return apiPath.post["x-hyperledger-cactus"].http.verbLowerCase;
return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase;
}

public getOperationId(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"paths": {
"/api/v1/plugins/@hyperledger/cactus-plugin-object-store-ipfs/get-object": {
"post": {
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-object-store-ipfs/get-object"
Expand All @@ -58,7 +58,7 @@
},
"/api/v1/plugins/@hyperledger/cactus-plugin-object-store-ipfs/set-object": {
"post": {
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-object-store-ipfs/set-object"
Expand All @@ -79,7 +79,7 @@
},
"/api/v1/plugins/@hyperledger/cactus-plugin-object-store-ipfs/has-object": {
"post": {
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-object-store-ipfs/has-object"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ export class GetObjectEndpointV1 implements IWebServiceEndpoint {
}

public getVerbLowerCase(): string {
return this.getOperation()["x-hyperledger-cactus"].http.verbLowerCase;
return this.getOperation()["x-hyperledger-cacti"].http.verbLowerCase;
}

public getPath(): string {
return this.getOperation()["x-hyperledger-cactus"].http.path;
return this.getOperation()["x-hyperledger-cacti"].http.path;
}

public getExpressRequestHandler(): IExpressRequestHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ export class HasObjectEndpointV1 implements IWebServiceEndpoint {
}

public getVerbLowerCase(): string {
return this.getOperation()["x-hyperledger-cactus"].http.verbLowerCase;
return this.getOperation()["x-hyperledger-cacti"].http.verbLowerCase;
}

public getPath(): string {
return this.getOperation()["x-hyperledger-cactus"].http.path;
return this.getOperation()["x-hyperledger-cacti"].http.path;
}

public getExpressRequestHandler(): IExpressRequestHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ export class SetObjectEndpointV1 implements IWebServiceEndpoint {
}

public getVerbLowerCase(): string {
return this.getOperation()["x-hyperledger-cactus"].http.verbLowerCase;
return this.getOperation()["x-hyperledger-cacti"].http.verbLowerCase;
}

public getPath(): string {
return this.getOperation()["x-hyperledger-cactus"].http.path;
return this.getOperation()["x-hyperledger-cacti"].http.path;
}

public getExpressRequestHandler(): IExpressRequestHandler {
Expand Down
6 changes: 3 additions & 3 deletions packages/cactus-cmd-api-server/src/main/json/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"get": {
"summary": "Can be used to verify liveness of an API server instance",
"description": "Returns the current timestamp of the API server as proof of health/liveness",
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "get",
"path": "/api/v1/api-server/healthcheck"
Expand All @@ -107,7 +107,7 @@
},
"/api/v1/api-server/get-prometheus-exporter-metrics": {
"get": {
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "get",
"path": "/api/v1/api-server/get-prometheus-exporter-metrics"
Expand All @@ -133,7 +133,7 @@
"/api/v1/api-server/get-open-api-spec": {
"get": {
"description": "Returns the openapi.json document of specific plugin.",
"x-hyperledger-cactus": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "get",
"path": "/api/v1/api-server/get-open-api-spec"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,9 @@ export class ApiServer {
oas: OAS,
oasPath,
operationId,
path: oasPath.get["x-hyperledger-cactus"].http.path,
path: oasPath.get["x-hyperledger-cacti"].http.path,
pluginRegistry,
verbLowerCase: oasPath.get["x-hyperledger-cactus"].http.verbLowerCase,
verbLowerCase: oasPath.get["x-hyperledger-cacti"].http.verbLowerCase,
logLevel,
};
const endpoint = new GetOpenApiSpecV1Endpoint(opts);
Expand All @@ -595,7 +595,7 @@ export class ApiServer {
};

const { "/api/v1/api-server/healthcheck": oasPath } = OAS.paths;
const { http } = oasPath.get["x-hyperledger-cactus"];
const { http } = oasPath.get["x-hyperledger-cacti"];
const { path: httpPath, verbLowerCase: httpVerb } = http;
if (!isExpressHttpVerbMethodName(httpVerb)) {
const eMsg = `${fnTag} Invalid HTTP verb "${httpVerb}" in cmd-api-server OpenAPI specification for HTTP path: "${httpPath}"`;
Expand Down Expand Up @@ -634,7 +634,7 @@ export class ApiServer {
} = OAS.paths;

const { http: httpPrometheus } =
oasPathPrometheus.get["x-hyperledger-cactus"];
oasPathPrometheus.get["x-hyperledger-cacti"];

const { path: httpPathPrometheus, verbLowerCase: httpVerbPrometheus } =
httpPrometheus;
Expand Down
Loading

0 comments on commit 31ac3f1

Please sign in to comment.