Response is different than in example
I have an issue with using an example and actual result, that mock server returns. Values are not in the same order.
I am using lastest docker image with environment:
- OPENAPI_MOCK_USE_EXAMPLES=if_present
Expected result:
{
"0_0": "0",
"1_1": "1",
"2_2": "2",
"3_3": "3",
"4_4": "4",
"5_5": "5",
"6_6": "6",
"7_7": "7",
"8_8": "8",
"9_9": "9",
"10_10": "10",
"11_11": "11",
"12_12": "12"
}
Actual result - values 10_10, 11_11 and 12_12 are not in the expected position.
{
"0_0": "0",
"10_10": "10",
"11_11": "11",
"12_12": "12",
"1_1": "1",
"2_2": "2",
"3_3": "3",
"4_4": "4",
"5_5": "5",
"6_6": "6",
"7_7": "7",
"8_8": "8",
"9_9": "9"
}
Openapi file:
{
"openapi": "3.0.3",
"info": {
"title": "Bug report",
"description": "Bug report",
"version": "1.0.0"
},
"servers": [
{
"url": "http://localhost:20002/",
"description": "Mockup server",
"variables": {
"port": {
"enum": [
"80"
],
"default": "80"
}
}
}
],
"paths": {
"/bug": {
"get": {
"description": "Bug report - example values mixed",
"responses": {
"200": {
"description": "Example",
"content": {
"application/json": {
"schema": {
"type": "object",
"title": "items",
"example": {
"0_0": "0",
"1_1": "1",
"2_2": "2",
"3_3": "3",
"4_4": "4",
"5_5": "5",
"6_6": "6",
"7_7": "7",
"8_8": "8",
"9_9": "9",
"10_10": "10",
"11_11": "11",
"12_12": "12"
}
}
}
}
}
}
}
}
}
}
Hello! This is because the map in Golang does not preserve the order of the attributes. Is it really needed? As I know JavaScript object does not guarantee the order of the attributes, see https://stackoverflow.com/questions/5525795/does-javascript-guarantee-object-property-order.
It's not really needed. I just came across this and I was expecting that response will be "copy & paste" from example without modifications.