BUG: Two dimensional array Not Support by CLI Plugin
See original GitHub issueI’m submitting a…
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
I use Cli Plugin that auto add @ApiProperty
. My DTO:
// ./dto/test-report.dto.ts
import { ValidateNested } from 'class-validator'
import { PlanExecutionDto } from './plan-execution.dto'
import { CreateTestReportDto } from './create-test-report.dto'
import { BugStatistics } from './bug-statistics.dto'
import { ManualPlanInfoDto } from './manual-plan-info.dto'
import { CaseExecutionDto } from './case-execution.dto'
import { ApiProperty } from '@nestjs/swagger'
export class TestReportDto {
@ValidateNested()
reportInfo!: CreateTestReportDto
@ValidateNested()
planInfo!: ManualPlanInfoDto
@ValidateNested({ each: true })
planExecution!: PlanExecutionDto[]
// Here is the error line
@ValidateNested({ each: true })
caseExecution!: CaseExecutionDto[][]
@ValidateNested()
bugStatistics!: BugStatistics
}
The Swagger Output Piar:
{
"components": {
"schemas": {
"TestReportDto": {
"type": "object",
"properties": {
"reportInfo": {
"description": "报告信息",
"allOf": [
{
"$ref": "#/components/schemas/CreateTestReportDto"
}
]
},
"planInfo": {
"description": "计划信息",
"allOf": [
{
"$ref": "#/components/schemas/ManualPlanInfoDto"
}
]
},
"planExecution": {
"description": "计划/轮次执行情况",
"type": "array",
"items": {
"$ref": "#/components/schemas/PlanExecutionDto"
}
},
"caseExecution": {
"type": "array",
"items": {
// Here is the error
"$ref": "#/components/schemas/"
}
},
"bugStatistics": {
"description": "Bug 统计",
"allOf": [
{
"$ref": "#/components/schemas/BugStatistics"
}
]
}
},
"required": [
"reportInfo",
"planInfo",
"planExecution",
"caseExecution",
"bugStatistics"
]
}
}
}
}
Expected behavior
The Swagger should be:
{
"components": {
"schemas": {
"TestReportDto": {
"type": "object",
"properties": {
"reportInfo": {
"description": "报告信息",
"allOf": [
{
"$ref": "#/components/schemas/CreateTestReportDto"
}
]
},
"planInfo": {
"description": "计划信息",
"allOf": [
{
"$ref": "#/components/schemas/ManualPlanInfoDto"
}
]
},
"planExecution": {
"description": "计划/轮次执行情况",
"type": "array",
"items": {
"$ref": "#/components/schemas/PlanExecutionDto"
}
},
// Here
"caseExecution": {
"type": "array",
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CaseExecutionDto"
}
}
},
"bugStatistics": {
"description": "Bug 统计",
"allOf": [
{
"$ref": "#/components/schemas/BugStatistics"
}
]
}
},
"required": [
"reportInfo",
"planInfo",
"planExecution",
"caseExecution",
"bugStatistics"
]
}
}
}
}
Minimal reproduction of the problem with instructions
- Create a nestjs project with cli plugin.
- add a DTO with Two dimensional array.
- Generate swagger
What is the motivation / use case for changing the behavior?
Two-dimensional arrays are very common in data structures.
Environment
Nest version: X.Y.Z
For Tooling issues:
- Node version: v14.16.1
- Platform: Mac
Others:
- @nestjs/core: 7.6.15
- @nestjs/swagger: 4.8.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Two-dimensional array in Swift - Stack Overflow
The 2D init using repeated values won't work. All the rows will point to the same sub-array, and thus no be uniquely writable....
Read more >Cannot read property 'version' of undefined #2866 - GitHub
Im using Version 4.0.2 (+ @vue/cli-service-global@4.0.2) , installed today :O Other versions: Node v10.8 / npm ...
Read more >Bug listing with status RESOLVED with resolution FIXED as at ...
Bug :2 - "How do I attach an ebuild. ... status:RESOLVED resolution:FIXED severity:enhancement · Bug:353 - "linux-sources: kdb module support will not build....
Read more >Multidimensional Arrays - MATLAB & Simulink - MathWorks
A multidimensional array in MATLAB® is an array with more than two dimensions. In a matrix, the two dimensions are represented by rows...
Read more >NVIDIA DRIVE OS Linux SDK API Reference ... - NVIDIA Developer
Not all geometry shader implementations have the ability to write the point size from ... A single layer of a two-dimensional array texture,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I will create a project tonight.
Let’s track this here https://github.com/nestjs/swagger/pull/1436