Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generation missing required properties for arrays #58

Merged
merged 3 commits into from
Jun 28, 2022
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
11 changes: 8 additions & 3 deletions src/main/java/org/spdx/tools/schema/OwlToJsonSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public ObjectNode convertToJsonSchema() {
ExtendedIterator<Ontology> ontologyIter = model.listOntologies();
if (ontologyIter.hasNext()) {
Ontology ont = ontologyIter.next();
String ontologyUri = ont.getURI();
String version = ont.getVersionInfo();
String ontologyUri = version == null ? ont.getURI() : ont.getURI() + "/" + version;
if (Objects.nonNull(ontologyUri)) {
root.put("$id", ontologyUri);
}
Expand Down Expand Up @@ -231,6 +232,10 @@ private void addClassProperties(OntClass spdxClass, ObjectNode jsonSchemaPropert
jsonSchemaProperties.set(MultiFormatStore.propertyNameToCollectionPropertyName(
checkConvertRenamedPropertyName(property.getLocalName())),
deriveListPropertySchema(property, restrictions));
if (!restrictions.isOptional() || restrictions.getMinCardinality() > 0) {
required.add(MultiFormatStore.propertyNameToCollectionPropertyName(
checkConvertRenamedPropertyName(property.getLocalName())));
}
} else {
jsonSchemaProperties.set(checkConvertRenamedPropertyName(property.getLocalName()), derivePropertySchema(property, restrictions));
if (!restrictions.isOptional()) {
Expand Down Expand Up @@ -322,9 +327,9 @@ private ObjectNode derivePropertySchema(OntProperty property, PropertyRestrictio
// check for AnyLicenseInfo - these are strings with the exception of the extractedLicensingInfos which are the actual license description
JsonNode description = propertySchema.get("description");
if (Objects.isNull(description)) {
propertySchema.put("description", "License expression");
propertySchema.put("description", "License expression. See SPDX Annex D for the license expression syntax.");
} else {
propertySchema.put("description", "License expression for "+checkConvertRenamedPropertyName(property.getLocalName())+". "+description.asText());
propertySchema.put("description", "License expression for "+checkConvertRenamedPropertyName(property.getLocalName())+". See SPDX Annex D for the license expression syntax. "+description.asText());
}
propertySchema.put(JSON_RESTRICTION_TYPE, JSON_TYPE_STRING);
} else if (Objects.nonNull(clazz) && SpdxElement.class.isAssignableFrom(clazz)) {
Expand Down