Skip to content

Commit

Permalink
Merge pull request #158 from swisspush/develop
Browse files Browse the repository at this point in the history
Release 0.9.14
  • Loading branch information
lbovet authored Nov 3, 2020
2 parents dde725c + e22c6c5 commit 04a0b36
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apikana",
"version": "0.9.13",
"version": "0.9.14",
"description": "Integrated tools for REST API design - アピ",
"main": "index.js",
"bin": {
Expand Down
50 changes: 21 additions & 29 deletions src/generate-avro.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,40 +375,32 @@ module.exports = function() {
doc: doc || contents.description || '',
};

if (contents.hasOwnProperty('$ref')) {
if (valid) {
enumProp.type = 'enum';
enumProp.symbols = contents.enum;
if (valid) {
var enumName = contents.id || `${name}${jsonSchemaAvro._enumSuffix}`;
if(enums[enumName] && sameArray(contents.enum, enums[enumName])) {
enumProp.type = enumName;
} else {
enumProp.type = 'string';
}
} else {
if (valid) {
var enumName = `${name}${jsonSchemaAvro._enumSuffix}`;
if(enums[enumName] && sameArray(contents.enum, enums[enumName])) {
enumProp.type = enumName;
} else {
if(enums[enumName]) {
var num = enumName.replace(/[^\d.]/g, '');
num = num + 1;
if(num > 1) {
var reg = new RegExp(num);
enumName = enumName.replace(reg, newVal);
} else {
enumName = enumName+"_1";
}
}
enumProp.type = {
type: 'enum',
name: enumName,
symbols: contents.enum
if(enums[enumName]) {
var num = enumName.replace(/[^\d.]/g, '');
num = num + 1;
if(num > 1) {
var reg = new RegExp(num);
enumName = enumName.replace(reg, newVal);
} else {
enumName = enumName+"_1";
}
enums[enumName] = contents.enum;
}
} else {
enumProp.type = "string"
enumProp.type = {
type: 'enum',
name: enumName,
symbols: contents.enum
}
enums[enumName] = contents.enum;
}
} else {
enumProp.type = "string"
}

if(enumProp.type != "string") {
enumProp.type = [ enumProp.type, 'string' ]
}
Expand Down

0 comments on commit 04a0b36

Please sign in to comment.