swagger-test-templates
swagger-test-templates copied to clipboard
Query params that are not required included in every request like 'optional_fields: 'DATA GOES HERE''
I have a configuration for test_gen with different combinations for query params for endpoint:
get: {
'200': [{
ordering: ['id'],
businessUnits: [businessUnits.businessUnit.id],
description: 'ordering and filter by business unit'
}, {
limit: 1,
offset: 1,
description: 'limit and offset'
}, {
businessUnitNames: [businessUnits.businessUnit.name],
description: 'filter by business unit names'
}, {
inet: ipRanges.results[1].startAddress,
description: 'filter by IPs or CIDRs'
}, {
tags: [annotationTags.results[0].id, annotationTags.results[1].id],
description: 'filter by annotation tags id'
}, {
tagNames: [annotationTags.results[0].name],
description: 'filter by annotation tags name'
}, {
optional_fields: ['annotation', 'attributionReasons', 'enclosingIpNetwork', 'latestObservationSnapshot', 'latestMapSnapshot'],
description: 'include optional fields'
}, {
limit: 10,
offset: 0,
businessUnitNames: [businessUnits.businessUnit.name],
tags: [annotationTags.results[0].id],
optional_fields: ['annotation', 'attributionReasons', 'enclosingIpNetwork', 'latestObservationSnapshot', 'latestMapSnapshot'],
description: 'limit, offset, filter by BU name and tags with included optional fields'
}]
}
}
All these params are not required, an example from spec:
description: >
Comma-separated string; Include the provided fields as part of the
serialized result.
in: query
name: optional_fields
required: false
type: array
collectionFormat: csv
items:
enum:
- enclosingIpNetwork
- latestObservationSnapshot
- latestMapSnapshot
- attributionReasons
- annotation
type: string
Why codegen includes all of them into request? Am I missing something?
qs: {
limit: 'DATA GOES HERE',offset: 'DATA GOES HERE',ordering: 'id',businessUnits: '95cac2f2-cf70-4bb1-af1d-14f143fbfb3a',businessUnitNames: 'DATA GOES HERE',inet: 'DATA GOES HERE',tags: 'DATA GOES HERE',tagNames: 'DATA GOES HERE',optional_fields: 'DATA GOES HERE'
},
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: process.env.JWT
}
},
function(error, res, body) {
if (error) return done(error);
res.statusCode.should.equal(200);
validator.validate(body, schema).should.be.true;
done();
});
Thanks in advance! :)