-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wire.API.UserMap & Brig.API.Public: Fix Swagger docs #1350
Conversation
The examples generated by swagger will not be nice, but it is very difficult to get it right, unless we want to add explicit examples everywhere. Perhaps we can use Arbitrary and some DerivingVia strategy to generate those. But for now, it doesn't seem like it is worth it.
Example generated by swagger-ui: {
"additionalProp1": {
"additionalProp1": [
{
"id": "string",
"type": "temporary",
"time": "2016-07-22T00:00:00Z",
"class": "phone",
"label": "string",
"cookie": "string",
"location": {
"lat": 0,
"lon": 0
},
"model": "string"
}
],
"additionalProp2": [
{
"id": "string",
"type": "temporary",
"time": "2016-07-22T00:00:00Z",
"class": "phone",
"label": "string",
"cookie": "string",
"location": {
"lat": 0,
"lon": 0
},
"model": "string"
}
],
"additionalProp3": [
{
"id": "string",
"type": "temporary",
"time": "2016-07-22T00:00:00Z",
"class": "phone",
"label": "string",
"cookie": "string",
"location": {
"lat": 0,
"lon": 0
},
"model": "string"
}
]
},
"additionalProp2": {
"additionalProp1": [
{
"id": "string",
"type": "temporary",
"time": "2016-07-22T00:00:00Z",
"class": "phone",
"label": "string",
"cookie": "string",
"location": {
"lat": 0,
"lon": 0
},
"model": "string"
}
],
"additionalProp2": [
{
"id": "string",
"type": "temporary",
"time": "2016-07-22T00:00:00Z",
"class": "phone",
"label": "string",
"cookie": "string",
"location": {
"lat": 0,
"lon": 0
},
"model": "string"
}
],
"additionalProp3": [
{
"id": "string",
"type": "temporary",
"time": "2016-07-22T00:00:00Z",
"class": "phone",
"label": "string",
"cookie": "string",
"location": {
"lat": 0,
"lon": 0
},
"model": "string"
}
]
},
"additionalProp3": {
"additionalProp1": [
{
"id": "string",
"type": "temporary",
"time": "2016-07-22T00:00:00Z",
"class": "phone",
"label": "string",
"cookie": "string",
"location": {
"lat": 0,
"lon": 0
},
"model": "string"
}
],
"additionalProp2": [
{
"id": "string",
"type": "temporary",
"time": "2016-07-22T00:00:00Z",
"class": "phone",
"label": "string",
"cookie": "string",
"location": {
"lat": 0,
"lon": 0
},
"model": "string"
}
],
"additionalProp3": [
{
"id": "string",
"type": "temporary",
"time": "2016-07-22T00:00:00Z",
"class": "phone",
"label": "string",
"cookie": "string",
"location": {
"lat": 0,
"lon": 0
},
"model": "string"
}
]
}
} |
Related issue in swagger2: GetShopTV/swagger2#136 |
|
Yes, the example is broken. This is a limitation of swagger2. It is not possible to model data like this. To get around this either we have to start writing examples of all the types that can appear in a map, or just rely on type names and descriptions to figure out what |
By default swagger-ui would generate "additionalProp1", "additionalProp2" .. for keys in each `Map` type. To get around this we provide examples explicitly. This results in weirdly named domains like '8v16tdys.s' being generated as well as empty lists but it seems to be better than "additionalProp1". This causes some of the lists in the examples to be empty, which is not very helpful as an example, perhaps there is a way to tweak this.
This is only slightly better but also uglier: {
"q.w403.qx8l": {
"00000001-0000-0000-0000-000200000002": [
{
"cookie": "",
"time": "1864-05-09T00:25:43.381Z",
"id": "1",
"type": "legalhold",
"label": ""
}
],
"00000001-0000-0001-0000-000100000002": []
},
"s3.5nz.5eseu02.k": {
"00000001-0000-0001-0000-000200000002": [],
"00000000-0000-0000-0000-000200000002": [
{
"cookie": "",
"time": "1864-05-09T12:12:47.740Z",
"location": {
"lat": 0,
"lon": 0
},
"model": "",
"id": "0",
"type": "permanent",
"class": "phone",
"label": ""
},
{
"time": "1864-05-09T17:16:12.806Z",
"id": "0",
"type": "legalhold",
"class": "desktop",
"label": ""
}
],
"00000000-0000-0002-0000-000000000002": []
},
"6eu8.w8l-8110": {
"00000001-0000-0002-0000-000200000001": [
{
"cookie": "",
"time": "1864-05-09T05:15:26.563Z",
"location": {
"lat": 0,
"lon": 0
},
"model": "",
"id": "1",
"type": "temporary",
"label": ""
}
],
"00000001-0000-0000-0000-000200000002": [
{
"cookie": "",
"time": "1864-05-09T02:36:33.750Z",
"location": {
"lat": 0,
"lon": 0
},
"model": "",
"id": "1",
"type": "permanent",
"label": ""
}
]
},
"8v16tdys.s": {},
"2e23p.f-q.l0.za5w99eeys0t8": {
"00000001-0000-0000-0000-000000000001": [],
"00000000-0000-0001-0000-000000000001": [],
"00000000-0000-0000-0000-000000000000": [],
"00000000-0000-0000-0000-000100000000": [],
"00000001-0000-0001-0000-000100000000": [],
"00000001-0000-0001-0000-000000000001": [],
"00000000-0000-0001-0000-000000000000": []
},
"n22.e017j": {
"00000001-0000-0000-0000-000000000001": [],
"00000002-0000-0002-0000-000100000001": [
{
"time": "1864-05-09T19:47:20.053Z",
"model": "",
"id": "0",
"type": "permanent",
"class": "legalhold",
"label": ""
},
{
"cookie": "",
"time": "1864-05-09T05:51:56.398Z",
"location": {
"lat": 0,
"lon": 0
},
"id": "1",
"type": "permanent",
"class": "legalhold",
"label": ""
}
],
"00000002-0000-0002-0000-000200000000": [
{
"cookie": "",
"time": "1864-05-09T09:36:28.408Z",
"location": {
"lat": 0,
"lon": 0
},
"model": "",
"id": "0",
"type": "temporary",
"class": "desktop"
},
{
"cookie": "",
"time": "1864-05-09T03:19:23.186Z",
"model": "",
"id": "1",
"type": "permanent",
"class": "tablet",
"label": ""
}
]
},
"b.c911viwc": {}
} |
@jschaul I think it is enough bikeshedding on this, I'll pick whichever solution you like. |
For WIre.API.UserMap:
The examples generated by swagger will not be nice, but it is very difficult to
get it right, unless we want to add explicit examples everywhere. Perhaps we can
use Arbitrary and some DerivingVia strategy to generate those. But for now, it
doesn't seem like it is worth it.