Skip to content

Commit

Permalink
Merge pull request #1092 from samchon/feat/swagger
Browse files Browse the repository at this point in the history
Avoid OpenAPI operation by `@hidden` comment tag.
  • Loading branch information
samchon authored Oct 30, 2024
2 parents c0b03b2 + f9df798 commit f4c3520
Show file tree
Hide file tree
Showing 115 changed files with 647 additions and 256 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@nestia/station",
"version": "3.17.0",
"version": "3.18.0",
"description": "Nestia station",
"scripts": {
"build": "node build/index.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/core",
"version": "3.17.0",
"version": "3.18.0",
"description": "Super-fast validation decorators of NestJS",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -36,7 +36,7 @@
},
"homepage": "https://nestia.io",
"dependencies": {
"@nestia/fetcher": "^3.17.0",
"@nestia/fetcher": "^3.18.0",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"@samchon/openapi": "^1.1.0",
Expand All @@ -53,7 +53,7 @@
"ws": "^7.5.3"
},
"peerDependencies": {
"@nestia/fetcher": ">=3.17.0",
"@nestia/fetcher": ">=3.18.0",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"reflect-metadata": ">=0.1.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/fetcher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/fetcher",
"version": "3.17.0",
"version": "3.18.0",
"description": "Fetcher library of Nestia SDK",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
10 changes: 5 additions & 5 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/sdk",
"version": "3.17.0",
"version": "3.18.0",
"description": "Nestia SDK and Swagger generator",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -32,8 +32,8 @@
},
"homepage": "https://nestia.io",
"dependencies": {
"@nestia/core": "^3.17.0",
"@nestia/fetcher": "^3.17.0",
"@nestia/core": "^3.18.0",
"@nestia/fetcher": "^3.18.0",
"@samchon/openapi": "^1.1.0",
"cli": "^1.0.1",
"get-function-location": "^2.0.0",
Expand All @@ -47,8 +47,8 @@
"typia": "^6.11.0"
},
"peerDependencies": {
"@nestia/core": ">=3.17.0",
"@nestia/fetcher": ">=3.17.0",
"@nestia/core": ">=3.18.0",
"@nestia/fetcher": ">=3.18.0",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"reflect-metadata": ">=0.1.12",
Expand Down
16 changes: 12 additions & 4 deletions packages/sdk/src/generates/SwaggerGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ export namespace SwaggerGenerator {
document: OpenApi.IDocument;
}): OpenApi.IDocument => {
// GATHER METADATA
const metadatas: Metadata[] = props.routes
.filter((r) => r.protocol === "http")
const routes: ITypedHttpRoute[] = props.routes.filter((r) =>
r.jsDocTags.every(
(tag) => tag.name !== "internal" && tag.name !== "hidden",
),
);
const metadatas: Metadata[] = routes
.map((r) => [
r.success.metadata,
...r.parameters.map((p) => p.metadata),
Expand All @@ -94,8 +98,12 @@ export namespace SwaggerGenerator {
const document: OpenApi.IDocument = props.document;
document.components.schemas ??= {};
Object.assign(document.components.schemas, json.components.schemas);
fillPaths({ ...props, schema, document });

fillPaths({
...props,
routes,
schema,
document,
});
return document;
};

Expand Down
2 changes: 1 addition & 1 deletion test/features/all/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "3.13.0-dev.2024910",
"version": "3.17.0",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "3.13.0-dev.2024910",
"version": "3.17.0",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/app-globalPrefix-versionUri/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "3.13.0-dev.2024910",
"version": "3.17.0",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/app-globalPrefix/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "3.13.0-dev.2024910",
"version": "3.17.0",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/app-routerModule/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "3.13.0-dev.2024910",
"version": "3.17.0",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/app-versionHeader/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "3.13.0-dev.2024910",
"version": "3.17.0",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/app-versionUri/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "3.13.0-dev.2024910",
"version": "3.17.0",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/app/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "3.13.0-dev.2024910",
"version": "3.17.0",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/beautify-4/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "3.13.0-dev.2024910",
"version": "3.17.0",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
2 changes: 1 addition & 1 deletion test/features/beautify-false/swagger.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"openapi":"3.1.0","servers":[{"url":"https://github.com/samchon/nestia","description":"insert your server url"}],"info":{"version":"3.13.0-dev.2024910","title":"@samchon/nestia-test","description":"Test program of Nestia","license":{"name":"MIT"}},"paths":{"/health":{"get":{"summary":"Health check API","description":"Health check API.\n\nJust for health checking API liveness.","tags":["system","health"],"parameters":[],"responses":{"200":{"description":"","content":{"application/json":{}}}}}},"/performance":{"get":{"summary":"Get server performance info","description":"Get server performance info.","tags":["system","performance"],"parameters":[],"responses":{"200":{"description":"Performance info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IPerformance"}}}}}}},"/body":{"post":{"summary":"Store an article","description":"Store an article.","tags":[],"parameters":[],"requestBody":{"description":"Content to store","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IBbsArticle.IStore"}}},"required":true},"responses":{"201":{"description":"Newly archived article","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IBbsArticle"}}}}}}},"/body/{id}":{"put":{"tags":[],"parameters":[{"name":"id","in":"path","schema":{"type":"string","format":"uuid"},"required":true}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartialIBbsArticle.IStore"}}},"required":true},"responses":{"200":{"description":"","content":{"application/json":{}}}}}}},"components":{"schemas":{"IPerformance":{"type":"object","properties":{"cpu":{"$ref":"#/components/schemas/process.global.NodeJS.CpuUsage"},"memory":{"$ref":"#/components/schemas/process.global.NodeJS.MemoryUsage"},"resource":{"$ref":"#/components/schemas/process.global.NodeJS.ResourceUsage"}},"required":["cpu","memory","resource"],"description":"Performance info."},"process.global.NodeJS.CpuUsage":{"type":"object","properties":{"user":{"type":"number"},"system":{"type":"number"}},"required":["user","system"]},"process.global.NodeJS.MemoryUsage":{"type":"object","properties":{"rss":{"type":"number"},"heapTotal":{"type":"number"},"heapUsed":{"type":"number"},"external":{"type":"number"},"arrayBuffers":{"type":"number"}},"required":["rss","heapTotal","heapUsed","external","arrayBuffers"]},"process.global.NodeJS.ResourceUsage":{"type":"object","properties":{"fsRead":{"type":"number"},"fsWrite":{"type":"number"},"involuntaryContextSwitches":{"type":"number"},"ipcReceived":{"type":"number"},"ipcSent":{"type":"number"},"majorPageFault":{"type":"number"},"maxRSS":{"type":"number"},"minorPageFault":{"type":"number"},"sharedMemorySize":{"type":"number"},"signalsCount":{"type":"number"},"swappedOut":{"type":"number"},"systemCPUTime":{"type":"number"},"unsharedDataSize":{"type":"number"},"unsharedStackSize":{"type":"number"},"userCPUTime":{"type":"number"},"voluntaryContextSwitches":{"type":"number"}},"required":["fsRead","fsWrite","involuntaryContextSwitches","ipcReceived","ipcSent","majorPageFault","maxRSS","minorPageFault","sharedMemorySize","signalsCount","swappedOut","systemCPUTime","unsharedDataSize","unsharedStackSize","userCPUTime","voluntaryContextSwitches"]},"IBbsArticle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"created_at":{"type":"string","format":"date-time"},"title":{"type":"string","minLength":3,"maxLength":50},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"required":["id","created_at","title","body","files"]},"IAttachmentFile":{"type":"object","properties":{"name":{"oneOf":[{"type":"null"},{"type":"string","maxLength":255}]},"extension":{"oneOf":[{"type":"null"},{"type":"string","minLength":1,"maxLength":8}]},"url":{"type":"string","format":"uri"}},"required":["name","extension","url"]},"IBbsArticle.IStore":{"type":"object","properties":{"title":{"type":"string","minLength":3,"maxLength":50},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"required":["title","body","files"]},"PartialIBbsArticle.IStore":{"type":"object","properties":{"title":{"type":"string","minLength":3,"maxLength":50},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"description":"Make all properties in T optional"}},"securitySchemes":{"bearer":{"type":"apiKey"}}},"tags":[{"name":"system"},{"name":"health"},{"name":"performance"}],"x-samchon-emended":true}
{"openapi":"3.1.0","servers":[{"url":"https://github.com/samchon/nestia","description":"insert your server url"}],"info":{"version":"3.17.0","title":"@samchon/nestia-test","description":"Test program of Nestia","license":{"name":"MIT"}},"paths":{"/health":{"get":{"summary":"Health check API","description":"Health check API.\n\nJust for health checking API liveness.","tags":["system","health"],"parameters":[],"responses":{"200":{"description":"","content":{"application/json":{}}}}}},"/performance":{"get":{"summary":"Get server performance info","description":"Get server performance info.","tags":["system","performance"],"parameters":[],"responses":{"200":{"description":"Performance info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IPerformance"}}}}}}},"/body":{"post":{"summary":"Store an article","description":"Store an article.","tags":[],"parameters":[],"requestBody":{"description":"Content to store","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IBbsArticle.IStore"}}},"required":true},"responses":{"201":{"description":"Newly archived article","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IBbsArticle"}}}}}}},"/body/{id}":{"put":{"tags":[],"parameters":[{"name":"id","in":"path","schema":{"type":"string","format":"uuid"},"required":true}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartialIBbsArticle.IStore"}}},"required":true},"responses":{"200":{"description":"","content":{"application/json":{}}}}}}},"components":{"schemas":{"IPerformance":{"type":"object","properties":{"cpu":{"$ref":"#/components/schemas/process.global.NodeJS.CpuUsage"},"memory":{"$ref":"#/components/schemas/process.global.NodeJS.MemoryUsage"},"resource":{"$ref":"#/components/schemas/process.global.NodeJS.ResourceUsage"}},"required":["cpu","memory","resource"],"description":"Performance info."},"process.global.NodeJS.CpuUsage":{"type":"object","properties":{"user":{"type":"number"},"system":{"type":"number"}},"required":["user","system"]},"process.global.NodeJS.MemoryUsage":{"type":"object","properties":{"rss":{"type":"number"},"heapTotal":{"type":"number"},"heapUsed":{"type":"number"},"external":{"type":"number"},"arrayBuffers":{"type":"number"}},"required":["rss","heapTotal","heapUsed","external","arrayBuffers"]},"process.global.NodeJS.ResourceUsage":{"type":"object","properties":{"fsRead":{"type":"number"},"fsWrite":{"type":"number"},"involuntaryContextSwitches":{"type":"number"},"ipcReceived":{"type":"number"},"ipcSent":{"type":"number"},"majorPageFault":{"type":"number"},"maxRSS":{"type":"number"},"minorPageFault":{"type":"number"},"sharedMemorySize":{"type":"number"},"signalsCount":{"type":"number"},"swappedOut":{"type":"number"},"systemCPUTime":{"type":"number"},"unsharedDataSize":{"type":"number"},"unsharedStackSize":{"type":"number"},"userCPUTime":{"type":"number"},"voluntaryContextSwitches":{"type":"number"}},"required":["fsRead","fsWrite","involuntaryContextSwitches","ipcReceived","ipcSent","majorPageFault","maxRSS","minorPageFault","sharedMemorySize","signalsCount","swappedOut","systemCPUTime","unsharedDataSize","unsharedStackSize","userCPUTime","voluntaryContextSwitches"]},"IBbsArticle":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"created_at":{"type":"string","format":"date-time"},"title":{"type":"string","minLength":3,"maxLength":50},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"required":["id","created_at","title","body","files"]},"IAttachmentFile":{"type":"object","properties":{"name":{"oneOf":[{"type":"null"},{"type":"string","maxLength":255}]},"extension":{"oneOf":[{"type":"null"},{"type":"string","minLength":1,"maxLength":8}]},"url":{"type":"string","format":"uri"}},"required":["name","extension","url"]},"IBbsArticle.IStore":{"type":"object","properties":{"title":{"type":"string","minLength":3,"maxLength":50},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"required":["title","body","files"]},"PartialIBbsArticle.IStore":{"type":"object","properties":{"title":{"type":"string","minLength":3,"maxLength":50},"body":{"type":"string"},"files":{"type":"array","items":{"$ref":"#/components/schemas/IAttachmentFile"}}},"description":"Make all properties in T optional"}},"securitySchemes":{"bearer":{"type":"apiKey"}}},"tags":[{"name":"system"},{"name":"health"},{"name":"performance"}],"x-samchon-emended":true}
2 changes: 1 addition & 1 deletion test/features/beautify/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "3.13.0-dev.2024910",
"version": "3.17.0",
"title": "@samchon/nestia-test",
"description": "Test program of Nestia",
"license": {
Expand Down
Loading

0 comments on commit f4c3520

Please sign in to comment.