-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
Description
Hi, thanks for providing such a library for the community. We are using redoc in our code and we found a potential issue in the generated JSON and we traced it down to this library. I compared the OpenAPI doc we generate using the https://editor.swagger.io/ to see if we were diverging from what is expected and apparently it is a bug here in openapi-sampler.
It happens when we use the OneOf and it generates the wrong output. To best exemplify, I created a test for the object.spec.js file.
Please let me know what you think.
it('should generate both items of oneOf', () => {
res = sampleObject({
'type': 'object',
'properties': {
'my_obj': {
'type': 'object',
'properties': {
'elements': {
'items': {
'oneOf': [
{
'type': 'object',
'properties': {
'name': {
'type': 'string',
'description': '',
'enum': [
'obj_a'
]
}
},
'title': 'obj_a',
'required': [
'name'
]
},
{
'type': 'object',
'properties': {
'name': {
'type': 'string',
'description': '',
'enum': [
'obj_b'
]
}
},
'title': 'obj_b',
'required': [
'name'
]
}
]
},
'type': 'array',
'minItems': 2,
'maxItems': 2,
'uniqueItems': true
}
},
'title': '',
'required': [
'elements'
]
}
},
'required': [
'my_obj'
]
})
expect(res).deep.equal({
'my_obj': {
'elements': [
{
'name': 'obj_a'
},
{
'name': 'obj_b'
}
]
}
})
});zebapy