Is there any way to define a HashMap or Generic Object type in the models section? I have a REST service that returns products and those products can have different options. The options property are basically a HashMap, where the id is the option name and its value is the option value.
相关问题
- Design RESTful service with multiple ids
- How to refer to an external JSON file containing r
- Axios OPTIONS instead of POST Request. Express Res
- Plain (non-HTML) error pages in REST api
- Laravel 5.1 MethodNotAllowedHttpException on store
相关文章
- 我用scrapy写了一个蛮简单的爬虫怎么封装成一个api啊
- 后端给前端的API接口是怎么用代码写的
- swagger3.0,版本的接口都没有了
- Convert C# Object to Json Object
- Android camera2 API get focus distance in AF mode
- Got ActiveRecord::AssociationTypeMismatch on model
- Multiple parameters in AngularJS $resource GET
- Global Exception Handling in Jersey & Spring?
Yes it's possible.
In OpenAPI (fka. Swagger) 2.0 and 3.0, a hashmap is always a
<string, something>
map:additionalProperties
.Let's say you want to describe a
<string, string>
hashmap like this one:The corresponding OpenAPI 2.0 definition will be:
In OpenAPI 3.0 the definition will be:
A
<string, object>
hashmap like thiswill be defined this way in OpenAPI 2.0:
and in OpenAPI 3.0:
I've just covered this in depth in part 4 of my OpenAPI (fka Swagger tutorial).
The OpenAPI (fka. Swagger) specification explains briefly this too.