mirror of
https://github.com/logto-io/logto.git
synced 2025-01-27 21:39:16 -05:00
chore(core): do not throw error for api doc integrity on prod
This commit is contained in:
parent
b05fb2960d
commit
2b28fd7d75
2 changed files with 9 additions and 3 deletions
|
@ -228,7 +228,9 @@ export default function swaggerRoutes<T extends AnonymousRouter, R extends Route
|
|||
|
||||
if (EnvSet.values.isUnitTest) {
|
||||
consoleLog.warn('Skip validating swagger document in unit test.');
|
||||
} else {
|
||||
}
|
||||
// Don't throw for integrity check in production as it has no benefit.
|
||||
else if (!EnvSet.values.isProduction || EnvSet.values.isIntegrationTest) {
|
||||
for (const document of supplementDocuments) {
|
||||
validateSupplement(baseDocument, document);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import { isKeyInObject, type Optional } from '@silverhand/essentials';
|
|||
import { OpenAPIV3 } from 'openapi-types';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { EnvSet } from '#src/env-set/index.js';
|
||||
import { consoleLog } from '#src/utils/console.js';
|
||||
|
||||
const capitalize = (value: string) => value.charAt(0).toUpperCase() + value.slice(1);
|
||||
|
@ -156,11 +155,16 @@ export const validateSupplement = (
|
|||
*/
|
||||
export const validateSwaggerDocument = (document: OpenAPIV3.Document) => {
|
||||
for (const [path, operations] of Object.entries(document.paths)) {
|
||||
if (!EnvSet.values.isProduction && path.startsWith('/api/interaction')) {
|
||||
if (path.startsWith('/api/interaction')) {
|
||||
consoleLog.warn(`Path \`${path}\` is not documented. Do something!`);
|
||||
continue;
|
||||
}
|
||||
|
||||
// This path is for admin tenant only, skip it.
|
||||
if (path === '/api/.well-known/endpoints/{tenantId}') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!operations) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue