Skip to content

Commit

Permalink
Merge pull request #291 from samchon/features/tags
Browse files Browse the repository at this point in the history
Support `@internal` and @deprecated` tags (SDK)
  • Loading branch information
samchon authored Mar 29, 2023
2 parents a6196d8 + 6f4ead8 commit 6322445
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 74 deletions.
7 changes: 7 additions & 0 deletions packages/sdk/demo/176/src/api/functional/userspace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import type { IConnection } from "@nestia/fetcher";
import type { Userspace } from "./../../structures/Userspace";

/**
* Type one.
*
* @returns something
* @deprecated
*
* @controller UserspaceController.type1()
* @path GET /userspace/type1
* @nestia Generated by Nestia - https://github.com/samchon/nestia
Expand Down Expand Up @@ -45,6 +50,8 @@ export namespace type1
}

/**
* @internal
*
* @controller UserspaceController.type2()
* @path GET /userspace/type2
* @nestia Generated by Nestia - https://github.com/samchon/nestia
Expand Down
9 changes: 9 additions & 0 deletions packages/sdk/demo/176/src/controllers/UserspaceController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@ import { Userspace } from "../api/structures/Userspace";

@nest.Controller("userspace")
export class UserspaceController {
/**
* Type one.
*
* @returns something
* @deprecated
*/
@core.TypedRoute.Get("type1")
public async type1(): Promise<Userspace.UserType1> {
return {
id: "some-id",
};
}

/**
* @internal
*/
@nest.Get("type2")
public async type2(): Promise<Userspace.UserType2> {
return {
Expand Down
59 changes: 15 additions & 44 deletions packages/sdk/demo/176/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"parameters": [],
"responses": {
"200": {
"description": "",
"description": "something",
"content": {
"application/json": {
"schema": {
Expand All @@ -28,31 +28,23 @@
"x-nestia-encrypted": false
}
},
"description": "",
"summary": "Type one",
"description": "Type one.",
"x-nestia-namespace": "userspace.type1.type1",
"x-nestia-jsDocTags": []
}
},
"/userspace/type2": {
"get": {
"tags": [],
"parameters": [],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Userspace.UserType2"
}
"x-nestia-jsDocTags": [
{
"name": "returns",
"text": [
{
"text": "something",
"kind": "text"
}
},
"x-nestia-encrypted": false
]
},
{
"name": "deprecated"
}
},
"description": "",
"x-nestia-namespace": "userspace.type2.type2",
"x-nestia-jsDocTags": []
]
}
}
},
Expand All @@ -72,27 +64,6 @@
"id"
],
"x-typia-jsDocTags": []
},
"Userspace.UserType2": {
"type": "object",
"properties": {
"id": {
"type": "string",
"nullable": false,
"x-typia-required": true
},
"name": {
"type": "string",
"nullable": false,
"x-typia-required": true
}
},
"nullable": false,
"required": [
"id",
"name"
],
"x-typia-jsDocTags": []
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import type { ISaleArticleComment } from "./../../../../../structures/ISaleArtic
* @param articleId ID of the target article
* @param input Content to write
* @return Newly archived comment
* @throw 400 bad request error when type of the input data is not valid
* @throw 401 unauthorized error when you've not logged in yet
* @throw 403 forbidden error when you're a seller and the sale is not yours
* @throw 404 not found error when unable to find the matched record
* @throws 400 bad request error when type of the input data is not valid
* @throws 401 unauthorized error when you've not logged in yet
* @throws 403 forbidden error when you're a seller and the sale is not yours
* @throws 404 not found error when unable to find the matched record
*
* @controller MultipleCommentsController.store()
* @path POST /consumers/:section/sales/:saleId/articles/:articleId/comments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import type { ISaleArticleComment } from "./../../../../../structures/ISaleArtic
* @param articleId ID of the target article
* @param input Content to write
* @return Newly archived comment
* @throw 400 bad request error when type of the input data is not valid
* @throw 401 unauthorized error when you've not logged in yet
* @throw 403 forbidden error when you're a seller and the sale is not yours
* @throw 404 not found error when unable to find the matched record
* @throws 400 bad request error when type of the input data is not valid
* @throws 401 unauthorized error when you've not logged in yet
* @throws 403 forbidden error when you're a seller and the sale is not yours
* @throws 404 not found error when unable to find the matched record
*
* @controller MultipleCommentsController.store()
* @path POST /sellers/:section/sales/:saleId/articles/:articleId/comments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export class MultipleCommentsController {
* @param input Content to write
* @return Newly archived comment
*
* @throw 400 bad request error when type of the input data is not valid
* @throw 401 unauthorized error when you've not logged in yet
* @throw 403 forbidden error when you're a seller and the sale is not yours
* @throw 404 not found error when unable to find the matched record
* @throws 400 bad request error when type of the input data is not valid
* @throws 401 unauthorized error when you've not logged in yet
* @throws 403 forbidden error when you're a seller and the sale is not yours
* @throws 404 not found error when unable to find the matched record
*/
@nest.Post([])
public async store(
Expand Down
16 changes: 8 additions & 8 deletions packages/sdk/demo/multiple-paths/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
]
},
{
"name": "throw",
"name": "throws",
"text": [
{
"text": "400 bad request error when type of the input data is not valid",
Expand All @@ -251,7 +251,7 @@
]
},
{
"name": "throw",
"name": "throws",
"text": [
{
"text": "401 unauthorized error when you've not logged in yet",
Expand All @@ -260,7 +260,7 @@
]
},
{
"name": "throw",
"name": "throws",
"text": [
{
"text": "403 forbidden error when you're a seller and the sale is not yours",
Expand All @@ -269,7 +269,7 @@
]
},
{
"name": "throw",
"name": "throws",
"text": [
{
"text": "404 not found error when unable to find the matched record",
Expand Down Expand Up @@ -451,7 +451,7 @@
]
},
{
"name": "throw",
"name": "throws",
"text": [
{
"text": "400 bad request error when type of the input data is not valid",
Expand All @@ -460,7 +460,7 @@
]
},
{
"name": "throw",
"name": "throws",
"text": [
{
"text": "401 unauthorized error when you've not logged in yet",
Expand All @@ -469,7 +469,7 @@
]
},
{
"name": "throw",
"name": "throws",
"text": [
{
"text": "403 forbidden error when you're a seller and the sale is not yours",
Expand All @@ -478,7 +478,7 @@
]
},
{
"name": "throw",
"name": "throws",
"text": [
{
"text": "404 not found error when unable to find the matched record",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestia/sdk",
"version": "1.0.17",
"version": "1.0.18",
"description": "Nestia SDK and Swagger generator",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
15 changes: 7 additions & 8 deletions packages/sdk/src/generates/FunctionGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ export namespace FunctionGenerator {
if (comments.length) comments.push("");

// FILTER TAGS (VULNERABLE PARAMETERS WOULD BE REMOVED)
const tagList: ts.JSDocTagInfo[] = route.tags.filter(
(tag) => tag.text !== undefined,
);
const tagList: ts.JSDocTagInfo[] = route.tags.slice();
if (tagList.length !== 0) {
const index: number = tagList.findIndex((t) => t.name === "param");
if (index !== -1) {
Expand All @@ -162,11 +160,12 @@ export namespace FunctionGenerator {
});
}
comments.push(
...tagList.map(
(tag) =>
`@${tag.name} ${tag
.text!.map((elem) => elem.text)
.join("")}`,
...tagList.map((tag) =>
tag.text
? `@${tag.name} ${tag.text
.map((elem) => elem.text)
.join("")}`
: `@${tag.name}`,
),
"",
);
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/generates/SwaggerGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export namespace SwaggerGenerator {
route.tags
.filter(
(tag) =>
tag.name === "throw" &&
(tag.name === "throw" || tag.name === "throws") &&
tag.text &&
tag.text.find(
(elem) =>
Expand Down

0 comments on commit 6322445

Please sign in to comment.