-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1111 from samchon/features/description
Close #1110: support `@description` tag in JSON schema.
- Loading branch information
Showing
15 changed files
with
156 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 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,34 @@ | ||
import typia from "typia"; | ||
|
||
/** | ||
* @title Something DTO | ||
* @description This is a description of the Something DTO. | ||
* | ||
* Let's fill the content of it. | ||
* @author Samchon | ||
*/ | ||
interface Something { | ||
/** | ||
* This is the title. | ||
* | ||
* This is the description. | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* This is not the description. | ||
* | ||
* @title Name | ||
* @description This is the description of the name | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* @description No title. | ||
* | ||
* Only description. | ||
*/ | ||
description: string; | ||
} | ||
|
||
console.log(JSON.stringify(typia.json.application<[Something]>(), null, 2)); |
This file contains 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 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 |
---|---|---|
|
@@ -32,6 +32,6 @@ | |
"typescript": "^5.3.2" | ||
}, | ||
"dependencies": { | ||
"typia": "../typia-6.1.1.tgz" | ||
"typia": "../typia-6.1.2.tgz" | ||
} | ||
} |
This file contains 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 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 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,12 @@ | ||
import { IJsDocTagInfo } from "../../module"; | ||
|
||
export const application_description = (props: { | ||
description: string | null | undefined; | ||
jsDocTags: IJsDocTagInfo[]; | ||
}): string | undefined => | ||
props.jsDocTags | ||
.find((tag) => tag.name === "description") | ||
?.text?.[0]?.text?.split("\r\n") | ||
.join("\n") ?? | ||
props.description ?? | ||
undefined; |
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -36,6 +36,6 @@ | |
"typescript": "^5.4.5" | ||
}, | ||
"dependencies": { | ||
"typia": "../typia-6.1.1.tgz" | ||
"typia": "../typia-6.1.2.tgz" | ||
} | ||
} |
This file contains 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
90 changes: 90 additions & 0 deletions
90
test/src/features/issues/test_issue_1100_json_description.ts
This file contains 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,90 @@ | ||
import { OpenApi } from "@samchon/openapi"; | ||
import typia, { IJsonApplication } from "typia"; | ||
|
||
import { TestValidator } from "../../helpers/TestValidator"; | ||
|
||
export const test_issue_1100_json_description = (): void => { | ||
const v30 = typia.json.application<[Something], "3.0">(); | ||
const v31 = typia.json.application<[Something], "3.1">(); | ||
|
||
validate(v30); | ||
validate(v31); | ||
}; | ||
|
||
const validate = ( | ||
app: IJsonApplication.IV3_0 | IJsonApplication.IV3_1, | ||
): void => { | ||
const something: OpenApi.IJsonSchema.IObject = (app.components.schemas as any) | ||
.Something; | ||
const id: OpenApi.IJsonSchema.IString = something.properties | ||
?.id as OpenApi.IJsonSchema.IString; | ||
const name: OpenApi.IJsonSchema.IString = something.properties | ||
?.name as OpenApi.IJsonSchema.IString; | ||
const description: OpenApi.IJsonSchema.IString = something.properties | ||
?.description as OpenApi.IJsonSchema.IString; | ||
|
||
TestValidator.equals("Something.description")({ | ||
title: something.title, | ||
description: something.description, | ||
})({ | ||
title: "Something DTO", | ||
description: [ | ||
"This is a description of the Something DTO.", | ||
"Let's fill the content of it.", | ||
].join("\n\n"), | ||
}); | ||
TestValidator.equals("Something.properties.id")({ | ||
title: id.title, | ||
description: id.description, | ||
})({ | ||
title: "This is the title", | ||
description: ["This is the title.", "This is the description."].join( | ||
"\n\n", | ||
), | ||
}); | ||
TestValidator.equals("Something.properties.name")({ | ||
title: name.title, | ||
description: name.description, | ||
})({ | ||
title: "Name", | ||
description: "This is the description of the name", | ||
}); | ||
TestValidator.equals("Something.properties.description")({ | ||
title: description.title, | ||
description: description.description, | ||
})({ | ||
title: undefined, | ||
description: ["No title.", "Only description."].join("\n\n"), | ||
}); | ||
}; | ||
|
||
/** | ||
* @title Something DTO | ||
* @description This is a description of the Something DTO. | ||
* | ||
* Let's fill the content of it. | ||
* @author Samchon | ||
*/ | ||
interface Something { | ||
/** | ||
* This is the title. | ||
* | ||
* This is the description. | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* This is not the description. | ||
* | ||
* @title Name | ||
* @description This is the description of the name | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* @description No title. | ||
* | ||
* Only description. | ||
*/ | ||
description: string; | ||
} |
This file contains 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