openapi-codegen-typescript
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -0,1 +1,13 @@ | ||
# v0.1.13 (Thu Sep 03 2020) | ||
#### 🐛 Bug Fix | ||
- fix(dictionary): fix codegen for boolean "dictionary" [#16](https://github.com/LandrAudio/openapi-codegen-typescript/pull/16) ([@nemrosim](https://github.com/nemrosim)) | ||
#### Authors: 1 | ||
- Artem Diashkin ([@nemrosim](https://github.com/nemrosim)) | ||
--- | ||
# v0.1.12 (Thu Sep 03 2020) | ||
@@ -2,0 +14,0 @@ |
@@ -153,26 +153,42 @@ "use strict"; | ||
var propertyName = _a.propertyName, xDictionaryKey = _a.xDictionaryKey, additionalProperties = _a.additionalProperties, DTOs = _a.DTOs; | ||
var dictionaryRef = MockGenerateHelper.parseRefType(xDictionaryKey[types_1.SwaggerProps.$ref].split('/')); | ||
var additionalRef = MockGenerateHelper.parseRefType(additionalProperties[types_1.SwaggerProps.$ref].split('/')); | ||
var dicSchema = DTOs[dictionaryRef]; | ||
var additionalSchema = DTOs[additionalRef]; | ||
// Enum key AND Enum value | ||
if (dicSchema && dicSchema.enum && additionalSchema && additionalSchema.enum) { | ||
var value_1 = "{ "; | ||
dicSchema.enum.forEach(function (el) { | ||
value_1 += "\n\"" + el + "\": \"" + additionalSchema.enum[0] + "\","; | ||
}); | ||
value_1 += "\n}"; | ||
return { propertyName: propertyName, value: value_1 }; | ||
if (xDictionaryKey[types_1.SwaggerProps.$ref]) { | ||
var dictionaryRef = MockGenerateHelper.parseRefType(xDictionaryKey[types_1.SwaggerProps.$ref].split('/')); | ||
var dicSchema = DTOs[dictionaryRef]; | ||
// Enum keys and Enum values | ||
if (additionalProperties[types_1.SwaggerProps.$ref]) { | ||
var additionalRef = MockGenerateHelper.parseRefType(additionalProperties[types_1.SwaggerProps.$ref].split('/')); | ||
var additionalSchema_1 = DTOs[additionalRef]; | ||
if (dicSchema && dicSchema.enum && additionalSchema_1 && additionalSchema_1.enum) { | ||
var value_1 = "{ "; | ||
dicSchema.enum.forEach(function (el) { | ||
value_1 += "\n\"" + el + "\": \"" + additionalSchema_1.enum[0] + "\","; | ||
}); | ||
value_1 += "\n}"; | ||
return { propertyName: propertyName, value: value_1 }; | ||
} | ||
} | ||
// Enum key and Object value | ||
if (dicSchema && dicSchema.enum && additionalProperties[types_1.SwaggerProps.$ref]) { | ||
var additionalRef_1 = MockGenerateHelper.parseRefType(additionalProperties[types_1.SwaggerProps.$ref].split('/')); | ||
var aOrAn_1 = indefinite_1.default(additionalRef_1, { articleOnly: true }); | ||
var value_2 = "{ "; | ||
dicSchema.enum.forEach(function (el) { | ||
value_2 += "\n\"" + el + "\": " + aOrAn_1 + additionalRef_1 + "API(),"; | ||
}); | ||
value_2 += "\n}"; | ||
return { propertyName: propertyName, value: value_2 }; | ||
} | ||
// Enum keys and Boolean values | ||
if (dicSchema && dicSchema.enum && additionalProperties.type === types_1.DataTypes.Boolean) { | ||
var value_3 = "{ "; | ||
dicSchema.enum.forEach(function (el) { | ||
value_3 += "\n\"" + el + "\": true,"; | ||
}); | ||
value_3 += "\n}"; | ||
return { propertyName: propertyName, value: value_3 }; | ||
} | ||
else { | ||
return { propertyName: propertyName, value: ' // TODO: Wrong dictionary type' }; | ||
} | ||
} | ||
// Enum key and Object value | ||
if (dicSchema && dicSchema.enum && additionalProperties) { | ||
var additionalRef_1 = MockGenerateHelper.parseRefType(additionalProperties[types_1.SwaggerProps.$ref].split('/')); | ||
var aOrAn_1 = indefinite_1.default(additionalRef_1, { articleOnly: true }); | ||
var value_2 = "{ "; | ||
dicSchema.enum.forEach(function (el) { | ||
value_2 += "\n\"" + el + "\": " + aOrAn_1 + additionalRef_1 + "API(),"; | ||
}); | ||
value_2 += "\n}"; | ||
return { propertyName: propertyName, value: value_2 }; | ||
} | ||
else { | ||
@@ -179,0 +195,0 @@ return { propertyName: propertyName, value: ' // TODO: Wrong dictionary type' }; |
@@ -153,5 +153,18 @@ "use strict"; | ||
if (xDictionaryKey && additionalProperties) { | ||
var dictionaryRef = parseRefType(xDictionaryKey[types_1.SwaggerProps.$ref].split('/')); | ||
var additionalRef = parseRefType(additionalProperties[types_1.SwaggerProps.$ref].split('/')); | ||
result += " " + propertyName + ": {\n[key in " + dictionaryRef + "]: " + additionalRef + "; \n }; \n"; | ||
// Enum keys and Enum/Object values | ||
if (xDictionaryKey[types_1.SwaggerProps.$ref] && additionalProperties[types_1.SwaggerProps.$ref]) { | ||
var dictionaryRef = parseRefType(xDictionaryKey[types_1.SwaggerProps.$ref].split('/')); | ||
var additionalRef = parseRefType(additionalProperties[types_1.SwaggerProps.$ref].split('/')); | ||
result += " " + propertyName + ": {\n[key in " + dictionaryRef + "]: " + additionalRef + "; \n }; \n"; | ||
// Enum keys and Boolean values | ||
} | ||
else if (xDictionaryKey[types_1.SwaggerProps.$ref]) { | ||
if (additionalProperties.type && additionalProperties.type === types_1.DataTypes.Boolean) { | ||
var dictionaryRef = parseRefType(xDictionaryKey[types_1.SwaggerProps.$ref].split('/')); | ||
result += " " + propertyName + ": {\n[key in " + dictionaryRef + "]: boolean; \n }; \n"; | ||
} | ||
} | ||
else { | ||
result += ' "// TODO: Something in wrong" '; | ||
} | ||
} | ||
@@ -158,0 +171,0 @@ }); |
{ | ||
"name": "openapi-codegen-typescript", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "OpenApi codegen for generating types an mocks from swagger json file", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61054
1144