-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cmd-api-server): swagger.json endpoints
fixes: #1877 Signed-off-by: adrianbatuto <[email protected]>
- Loading branch information
1 parent
e54842d
commit 5a5d78f
Showing
10 changed files
with
383 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/cactus-cmd-api-server/src/main/typescript/openapi/get-open-api-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Checks } from "@hyperledger/cactus-common"; | ||
import { PluginRegistry } from "@hyperledger/cactus-core"; | ||
import { | ||
ICactusPlugin, | ||
IPluginWebService, | ||
isIPluginWebService, | ||
} from "@hyperledger/cactus-core-api"; | ||
import type { OpenAPIV3 } from "express-openapi-validator/dist/framework/types"; | ||
|
||
export async function getOpenApiSpec( | ||
pluginRegistry: PluginRegistry, | ||
): Promise<OpenAPIV3.Document[]> { | ||
Checks.truthy( | ||
pluginRegistry, | ||
`openApiSpec() | ||
pluginRegistry (PluginRegistry)`, | ||
); | ||
|
||
const openApiJsonSpecsPromises = pluginRegistry | ||
.getPlugins() | ||
.filter((pluginInstance) => isIPluginWebService(pluginInstance)) | ||
.map(async (plugin: ICactusPlugin) => { | ||
const webPlugin = plugin as IPluginWebService; | ||
const openApiSpec = (await webPlugin.getOpenApiSpec()) as OpenAPIV3.Document; | ||
return openApiSpec; | ||
}); | ||
|
||
const openApiJsonSpecs = await Promise.all(openApiJsonSpecsPromises); | ||
return openApiJsonSpecs; | ||
} |
Oops, something went wrong.