diff --git a/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/extensions/scaffold-content.xqy b/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/extensions/scaffold-content.xqy index 1675d444da..fc8ac1c313 100644 --- a/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/extensions/scaffold-content.xqy +++ b/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/extensions/scaffold-content.xqy @@ -338,6 +338,9 @@ service:generate-lets($model, $entity-type-name, $mapping, $entity) let $properties := map:get($entity-type, "properties") let $required-properties := ( map:get($entity-type, "primaryKey"), + if (fn:empty(map:get($entity-type, "required"))) then + () + else json:array-values(map:get($entity-type, "required")) ) for $property-name in map:keys($properties) diff --git a/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/hub-entities.xqy b/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/hub-entities.xqy index 51de87cb33..c73bbc1649 100644 --- a/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/hub-entities.xqy +++ b/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/hub-entities.xqy @@ -38,16 +38,19 @@ declare function hent:get-model($entity-name as xs:string, $used-models as xs:st return let $model-map as map:map? := $model let $refs := $model//*[fn:local-name(.) = '$ref'][fn:starts-with(., "#/definitions")] ! fn:replace(., "#/definitions/", "") - let $_ := - let $definitions := map:get($model-map, "definitions") - for $ref in $refs[fn:not(. = $used-models)] - let $other-model as map:map? := hent:get-model($ref, ($used-models, $entity-name)) - let $other-defs := map:get($other-model, "definitions") - for $key in map:keys($other-defs) - return - map:put($definitions, $key, map:get($other-defs, $key)) - return - $model-map + let $definitions := map:get($model-map, "definitions") + let $_ := + for $ref in $refs[fn:not(. = $used-models)] + let $m := + if (fn:empty(map:get($definitions, $ref))) then + let $other-model as map:map? := hent:get-model($ref, ($used-models, $entity-name)) + let $other-defs := map:get($other-model, "definitions") + for $key in map:keys($other-defs) + return + map:put($definitions, $key, map:get($other-defs, $key)) + else () + return () + return $model-map }; declare function hent:uber-model() as map:map