Skip to content

Commit

Permalink
fix: remove choice type [x] generate in schema
Browse files Browse the repository at this point in the history
fix: remove choice type [x] generate in schema
  • Loading branch information
Chinlinlee authored Jan 22, 2022
2 parents 12a65c9 + 309ce6b commit f3a35b7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions FHIR-mongoose-Models-Generator/resourceGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function getSchema (resource , name) {
if (skipCol.indexOf(i) >= 0 ) continue;
else if (i.indexOf("_") == 0 ) continue;
let type = _.get(resource.properties[i] , "type");
let choiceType = isChoiceType(i);
//let choiceType = isChoiceType(i);
let refSchema = _.get(resource.properties[i] , "$ref");
let isCode = _.get(resource.properties[i] , "enum");
if (type == 'array') {
Expand All @@ -89,15 +89,15 @@ function getSchema (resource , name) {
let arrayRefClean = arrayRef.split('/');
let typeOfField = arrayRefClean[arrayRefClean.length-1];
if (typeOfField == name) typeOfField = "this"; //The type of field reference self
if (choiceType.yes) typeOfField = choiceType.type;
//if (choiceType.yes) typeOfField = choiceType.type;
result[i] = {
type : `[${typeOfField}]`
}
} else if (refSchema) {
if (/^#/.test(refSchema)) {
let refClean = refSchema.split('/');
let typeOfField = refClean[refClean.length-1];
if (choiceType.yes) typeOfField = choiceType.type;
//if (choiceType.yes) typeOfField = choiceType.type;
if (isPrimitiveType(typeOfField)) {
result[i] = typeOfField;
} else {
Expand All @@ -109,7 +109,7 @@ function getSchema (resource , name) {
} else if (!/^#/.test(refSchema)) {
let refClean = refSchema.split('/');
let typeOfField = refClean[refClean.length-1];
if (choiceType.yes) typeOfField = choiceType.type;
//if (choiceType.yes) typeOfField = choiceType.type;
if (isPrimitiveType(typeOfField)) {
result[i] = typeOfField;
} else {
Expand All @@ -126,7 +126,7 @@ function getSchema (resource , name) {
enum : JSON.stringify(isCode)
}
} else {
if (choiceType.yes) type = choiceType.type;
//if (choiceType.yes) type = choiceType.type;
if (isPrimitiveType(type)) {
result[i] = type;
} else {
Expand All @@ -135,9 +135,9 @@ function getSchema (resource , name) {
}
}
}
let isrequired = _.get(resource , "required");
if (isrequired) {
for (let item of isrequired) {
let isRequired = _.get(resource , "required");
if (isRequired) {
for (let item of isRequired) {
if (item == i) {
Object.assign(result[i] , {required : true});
}
Expand Down

0 comments on commit f3a35b7

Please sign in to comment.