-
Notifications
You must be signed in to change notification settings - Fork 5
feat(all-services): add openapi documentation files to arc-saas services #123
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,48 @@ | ||
| { | ||
| "openapi": "3.0.0", | ||
| "info": { | ||
| "title": "@sourceloop/ctrl-plane-orchestrator-service", | ||
| "version": "1.2.0", | ||
| "description": "ARC SaaS Orchestrator service.", | ||
| "contact": { | ||
| "name": "SourceFuse" | ||
| } | ||
| }, | ||
| "paths": { | ||
| "/ping": { | ||
| "get": { | ||
| "x-controller-name": "PingController", | ||
| "x-operation-name": "ping", | ||
| "tags": [ | ||
| "PingController" | ||
| ], | ||
| "responses": { | ||
| "200": { | ||
| "description": "Return value of PingController.ping" | ||
| } | ||
| }, | ||
| "operationId": "PingController.ping" | ||
| } | ||
| }, | ||
| "/": { | ||
| "get": { | ||
| "x-controller-name": "HomePageController", | ||
| "x-operation-name": "homePage", | ||
| "tags": [ | ||
| "HomePageController" | ||
| ], | ||
| "responses": { | ||
| "200": { | ||
| "description": "Return value of HomePageController.homePage" | ||
| } | ||
| }, | ||
| "operationId": "HomePageController.homePage" | ||
| } | ||
| } | ||
| }, | ||
| "servers": [ | ||
| { | ||
| "url": "/" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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,130 @@ | ||
| --- | ||
| title: "@sourceloop/ctrl-plane-orchestrator-service v1.2.0" | ||
| language_tabs: | ||
| - javascript: JavaScript | ||
| - javascript--nodejs: Node.JS | ||
| language_clients: | ||
| - javascript: request | ||
| - javascript--nodejs: "" | ||
| toc_footers: [] | ||
| includes: [] | ||
| search: true | ||
| highlight_theme: darkula | ||
| headingLevel: 2 | ||
|
|
||
| --- | ||
|
|
||
| <!-- Generator: Widdershins v4.0.1 --> | ||
|
|
||
| <h1 id="-sourceloop-ctrl-plane-orchestrator-service">@sourceloop/ctrl-plane-orchestrator-service v1.2.0</h1> | ||
|
|
||
| > Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu. | ||
|
|
||
| ARC SaaS Orchestrator service. | ||
|
|
||
| Base URLs: | ||
|
|
||
| * <a href="/">/</a> | ||
|
|
||
| <h1 id="-sourceloop-ctrl-plane-orchestrator-service-pingcontroller">PingController</h1> | ||
|
|
||
| ## PingController.ping | ||
|
|
||
| <a id="opIdPingController.ping"></a> | ||
|
|
||
| > Code samples | ||
|
|
||
| ```javascript | ||
|
|
||
| fetch('/ping', | ||
| { | ||
| method: 'GET' | ||
|
|
||
| }) | ||
| .then(function(res) { | ||
| return res.json(); | ||
| }).then(function(body) { | ||
| console.log(body); | ||
| }); | ||
|
|
||
| ``` | ||
|
|
||
| ```javascript--nodejs | ||
| const fetch = require('node-fetch'); | ||
|
|
||
| fetch('/ping', | ||
| { | ||
| method: 'GET' | ||
|
|
||
| }) | ||
| .then(function(res) { | ||
| return res.json(); | ||
| }).then(function(body) { | ||
| console.log(body); | ||
| }); | ||
|
|
||
| ``` | ||
|
|
||
| `GET /ping` | ||
|
|
||
| <h3 id="pingcontroller.ping-responses">Responses</h3> | ||
|
|
||
| |Status|Meaning|Description|Schema| | ||
| |---|---|---|---| | ||
| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Return value of PingController.ping|None| | ||
|
|
||
| <aside class="success"> | ||
| This operation does not require authentication | ||
| </aside> | ||
|
|
||
| <h1 id="-sourceloop-ctrl-plane-orchestrator-service-homepagecontroller">HomePageController</h1> | ||
|
|
||
| ## HomePageController.homePage | ||
|
|
||
| <a id="opIdHomePageController.homePage"></a> | ||
|
|
||
| > Code samples | ||
|
|
||
| ```javascript | ||
|
|
||
| fetch('/', | ||
| { | ||
| method: 'GET' | ||
|
|
||
| }) | ||
| .then(function(res) { | ||
| return res.json(); | ||
| }).then(function(body) { | ||
| console.log(body); | ||
| }); | ||
|
|
||
| ``` | ||
|
|
||
| ```javascript--nodejs | ||
| const fetch = require('node-fetch'); | ||
|
|
||
| fetch('/', | ||
| { | ||
| method: 'GET' | ||
|
|
||
| }) | ||
| .then(function(res) { | ||
| return res.json(); | ||
| }).then(function(body) { | ||
| console.log(body); | ||
| }); | ||
|
|
||
| ``` | ||
|
|
||
| `GET /` | ||
|
|
||
| <h3 id="homepagecontroller.homepage-responses">Responses</h3> | ||
|
|
||
| |Status|Meaning|Description|Schema| | ||
| |---|---|---|---| | ||
| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Return value of HomePageController.homePage|None| | ||
|
|
||
| <aside class="success"> | ||
| This operation does not require authentication | ||
| </aside> | ||
|
|
This file contains hidden or 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 hidden or 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,31 @@ | ||
| // Copyright (c) 2023 Sourcefuse Technologies | ||
| // | ||
| // This software is released under the MIT License. | ||
| // https://opensource.org/licenses/MIT | ||
| import {BootMixin} from '@loopback/boot'; | ||
| import {ApplicationConfig} from '@loopback/core'; | ||
| import {RepositoryMixin} from '@loopback/repository'; | ||
| import {RestApplication} from '@loopback/rest'; | ||
| import * as path from 'node:path'; | ||
| import {OrchestratorServiceComponent} from './component'; | ||
|
|
||
| export {ApplicationConfig}; | ||
|
|
||
| export class OrchestratorServiceApplication extends BootMixin( | ||
| RepositoryMixin(RestApplication), | ||
| ) { | ||
| constructor(options: ApplicationConfig = {}) { | ||
| super(options); | ||
| this.static('/', path.join(__dirname, '../public')); | ||
| this.component(OrchestratorServiceComponent); | ||
|
|
||
| this.projectRoot = __dirname; | ||
| this.bootOptions = { | ||
| controllers: { | ||
| dirs: ['controllers'], | ||
| extensions: ['.controller.js'], | ||
| nested: true, | ||
| }, | ||
| }; | ||
| } | ||
| } |
This file contains hidden or 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 @@ | ||
| // Copyright (c) 2023 Sourcefuse Technologies | ||
| // | ||
| // This software is released under the MIT License. | ||
| // https://opensource.org/licenses/MIT | ||
| import {ApplicationConfig} from '@loopback/core'; | ||
| import {OrchestratorServiceApplication} from './application'; | ||
|
|
||
| const PORT = 3000; | ||
| const ARGV_INDEX = 2; | ||
|
|
||
| /** | ||
| * Export the OpenAPI spec from the application | ||
| */ | ||
| async function exportOpenApiSpec(): Promise<void> { | ||
| const config: ApplicationConfig = { | ||
| rest: { | ||
| port: +(process.env.PORT ?? PORT), | ||
| host: process.env.HOST ?? 'localhost', | ||
| }, | ||
| }; | ||
| const outFile = process.argv[ARGV_INDEX] ?? './openapi.json'; | ||
| const app = new OrchestratorServiceApplication(config); | ||
| await app.boot(); | ||
| await app.exportOpenApiSpec(outFile); | ||
| } | ||
|
|
||
| exportOpenApiSpec().catch(err => { | ||
| console.error('Fail to export OpenAPI spec from the application.', err); //NOSONAR | ||
| process.exit(1); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things on the doc generation here (same applies to subscription-service and tenant-management-service — identical scripts):
npx widdershinsresolves and downloads widdershins from the registry at build time — non-deterministic (picks up new releases), network-dependent (fails on offline/air-gapped CI or a registry blip), and slow on a clean environment. Sincebuildnow callsapidocs, a bad widdershins release would break every build of every service. Pin it as a devDependency and call the local bin:build: lb-tsc && npm run openapi-spec && npm run apidocscouples doc generation into the standard build that Docker/deploy run, and sincepreopenapi-specislb-tsc, the compile runs twice per build. Consider keepingbuildas justlb-tsc, moving docs to a dedicated script, and adding a CI step that regenerates and fails if the committed spec drifted:Keeps deploy builds offline-safe and avoids the double compile while still guaranteeing the committed spec matches the code.