Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions lib/nodegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,25 @@ function function2node(data, options) {
function swagger2node(data, options) {
// Modify swagger data
var swagger = JSON.parse(JSON.stringify(data.src), function (key, value) {
if (key === 'consumes') { // 1. Filter type for 'Content-Type' in request header
return undefined;
} else if (key === 'produces') { // 2. Filter type for 'Accept' in request header
if (key === 'consumes' || key === 'produces') { // Filter type of 'Content-Type' and 'Accept' in request header
if (value.indexOf('application/json') >= 0) {
return ['application/json'];
}
if (value.indexOf('application/xml') >= 0) {
} else if (value.indexOf('application/xml') >= 0) {
return ['application/xml'];
} else if (value.indexOf('text/csv') >= 0) {
return ['text/csv'];
} else if (value.indexOf('text/plain') >= 0) {
return ['text/plain'];
} else if (value.indexOf('multipart/form-data') >= 0) {
return ['multipart/form-data'];
} else if (value.indexOf('application/octet-stream') >= 0) {
return ['application/octet-stream'];
} else {
return [value[0]];
return undefined;
}
} else if (key === 'default') { // 3. Handle swagger-js-codegen bug
} else if (key === 'default') { // Handle swagger-js-codegen bug
return undefined;
} else if (key === 'operationId') { // 4. Sanitize 'operationId' (remove special chars)
} else if (key === 'operationId') { // Sanitize 'operationId' (remove special chars)
return value.replace(/(?!\w|\s)./g, '');
} else {
return value;
Expand Down