Skip to content
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

Feature: Document server - redoc #38

Merged
merged 8 commits into from
Aug 31, 2022
Merged

Feature: Document server - redoc #38

merged 8 commits into from
Aug 31, 2022

Conversation

oscar60310
Copy link
Contributor

@oscar60310 oscar60310 commented Aug 23, 2022

Description

Host redoc on /doc path (configurable) and provide restful API spec.

Note

  1. For mounting different APIs, I moved Vulcan API under /api prefix, e.g. /user -> /api/user .
  2. I removed the fallback data from formaters because they erase the plain text content.

@oscar60310 oscar60310 changed the base branch from develop to chore/codecov-flag August 23, 2022 07:49
@codecov-commenter
Copy link

codecov-commenter commented Aug 23, 2022

Codecov Report

Base: 91.86% // Head: 92.08% // Increases project coverage by +0.21% 🎉

Coverage data is based on head (7f31291) compared to base (a608f57).
Patch coverage: 96.29% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #38      +/-   ##
===========================================
+ Coverage    91.86%   92.08%   +0.21%     
===========================================
  Files          208      215       +7     
  Lines         2901     2980      +79     
  Branches       345      346       +1     
===========================================
+ Hits          2665     2744      +79     
  Misses         172      172              
  Partials        64       64              
Flag Coverage Δ
build 94.87% <100.00%> (+0.63%) ⬆️
cli 91.90% <ø> (ø)
core 92.45% <100.00%> (+0.14%) ⬆️
extension-dbt 97.43% <ø> (ø)
extension-debug-tools 98.11% <ø> (ø)
integration-testing 96.42% <ø> (ø)
serve 88.82% <94.73%> (+0.58%) ⬆️
test-utility ∅ <ø> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/build/src/containers/types.ts 100.00% <ø> (ø)
...generator/spec-generator/oas3/oas3SpecGenerator.ts 97.33% <ø> (-0.04%) ⬇️
packages/build/src/models/index.ts 100.00% <ø> (ø)
packages/build/src/options/index.ts 100.00% <ø> (ø)
packages/core/src/containers/types.ts 100.00% <ø> (ø)
packages/serve/src/containers/types.ts 100.00% <ø> (ø)
...s/serve/src/models/extensions/responseFormatter.ts 100.00% <ø> (ø)
...erve/src/lib/route/route-component/restfulRoute.ts 93.33% <66.66%> (-6.67%) ⬇️
...ages/serve/src/models/extensions/documentRouter.ts 84.61% <84.61%> (ø)
...uter/redoc-document-router/redocDocumentRouters.ts 96.66% <96.66%> (ø)
... and 20 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@oscar60310 oscar60310 force-pushed the feature/doc-server branch 3 times, most recently from 6d4802a to 3716047 Compare August 24, 2022 06:32
@oscar60310 oscar60310 changed the title [WIP] Feature: Document server Feature: Document server Aug 24, 2022
@oscar60310 oscar60310 marked this pull request as ready for review August 24, 2022 06:41
@oscar60310 oscar60310 requested a review from kokokuo August 24, 2022 06:43
@oscar60310 oscar60310 changed the title Feature: Document server Feature: Document server - redoc Aug 24, 2022
Base automatically changed from chore/codecov-flag to develop August 26, 2022 06:22
Copy link
Contributor

@kokokuo kokokuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beside some some suggestion, others LGTM 👍

import { TYPES } from '@vulcan-sql/serve/containers';
import * as compose from 'koa-compose';

@VulcanInternalExtension()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about to setup the all different document server type under one options module name, because seems different document server extensions both use the same DocumentOptions.

like below:

api-doc:
  spec: [oas3]
  server: [redoc, ...]

And your document server middleware read the doc options, and according to your server to create each document type server ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to change to property name from document to api-doc and turn it from internal options to module configuration?

I think it will be great for renaming, but because it a cross-package config, that is, spec for both build and serve package and server for serve package, I'd prefer to use internal options to do some validations.

import * as path from 'path';
import { inject } from 'inversify';

@VulcanInternalExtension('redoc')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow by above documentServerMiddleware suggestion. Here the @VulcanInternalExtension('redoc') may could change to documentServerMiddleware internal extension module name ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it makes sense to merge the options of redoc with 'api-doc' options because it is a built-in router, but I'll prefer using internal options instead of module configuration.

/** Target specification of our APIs, e.g. OpenAPI, Tinyspec ...etc. */
specs?: (string | DocumentSpec)[];
folderPath?: string;
server?: (string | DocumentServerType)[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could rename the propety server and DocumentServerType e.g: from server To the renderType, and the DocumentRenderType or DocumentRouterType DocumentType?

Because seems that each document server extension still uses the same port in vulcan server with a different router.

If we use the server, it looks like each document server type use a different port to launch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar suggestion for documentServerMiddleware and documentServer extension, we could change the server to another word, e.g: render, router... and so on, to prevent each document server will create a new server with a different port

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I think router will be better, I'll update all of them.

@oscar60310
Copy link
Contributor Author

@kokokuo I've solve the conflicts and issues, thanks a lot.

Copy link
Contributor

@kokokuo kokokuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Thanks ~

@kokokuo kokokuo merged commit 9a03213 into develop Aug 31, 2022
@kokokuo kokokuo deleted the feature/doc-server branch August 31, 2022 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants