Being able to create types on ApiModelProperty for complex nested arrays (eg. GeoJSON)
See original GitHub issueI’m submitting a…
[ ] Regression
[ ] Bug report
[X ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
Right now, it’s impossible to express deeply nested array structures, such as the one that is needed to define Polygon coordinates in GeoJSON. eg:
[
[
[-122.38005638122557, 37.60376025592665],
[-122.37773895263672, 37.60593620261328],
[-122.36555099487303, 37.600632221054056],
[-122.34992980957031, 37.61858263247881],
[-122.38417625427246, 37.6399950678721],
[-122.39996910095215, 37.63809199009653],
[-122.39705085754393, 37.63251841048015],
[-122.39996910095215, 37.6315667819348],
[-122.40159988403319, 37.62918765725775],
[-122.3964500427246, 37.61416342563735],
[-122.38005638122557, 37.60376025592665],
],
]
Expected behavior
I think it would work best if we were able to pass in a raw object to the type
attribute of the ApiModelProperty decorator. Essentially something that allows us to define the raw type structure of something like the above. eg:
@ApiModelProperty({
description:
'A polygon shape that defines the geo fence. See "coordinates" key of the ' +
'Polygon geometry here: https://en.wikipedia.org/wiki/GeoJSON#Geometries',
type: {
type: 'array',
items: {
type: 'array',
items: {
type: 'array',
items: {
type: 'number',
},
},
},
},
required: true,
})
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Complex JSON nesting of objects and arrays - Stack Overflow
The first code is an example of Javascript code, which is similar, however not JSON. JSON would not have 1) comments and 2)...
Read more >Swagger RESTful API Documentation Specification
The Swagger specification supports five data types: primitive (input/output); containers (as arrays/sets) (input/output); complex (as models ) ...
Read more >Springfox Reference Documentation - GitHub Pages
Springfox works by examining an application, once, at runtime to infer API semantics based on spring configurations, class structure and various ...
Read more >Querying arrays with complex types and nested structures
Your source data often contains arrays with complex data types and nested structures. Examples in this section show how to change element's data...
Read more >Body - Nested Models - FastAPI
That's all standard Python syntax for type declarations. Use that same standard syntax for model attributes with internal types. So, in our example,...
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
Added in the
next
version (to install runnpm i @nestjs/swagger@next
). Note: remember to update@nestjs/common
,@nestjs/core
andtypescript
as well to ensure that you’re using the latest versions.Steps to migrate: https://github.com/nestjs/swagger/pull/355#issuecomment-547925879
@kamilmysliwiec I have submitted a PR for this, please give it a review.