specification icon indicating copy to clipboard operation
specification copied to clipboard

Unique titles for JSON schema definitions

Open howardj99 opened this issue 2 years ago • 3 comments

When generating Python pydantic models from the released CycloneDX schemas using datamodel-code-generator with the --use-title-as-name flag, several model classes are created with names such as Type (naming collision with typing.Type class), Type1, Type2, etc. due to duplicate definition title properties in the schemas.

Would it be feasible to make these definition titles unique and more descriptive of what they represent to enhance automated generation of models? Example of suggested changes:

Schema path Current Proposed Generated model class
.definitions.dataClassification.title "Hash objects" "Data Classification" DataClassification
.definitions.issue.title "Diff" "Issue" Issue
.definitions.externalReference.properties.type.title "Type" "External Reference Type" ExternalReferenceType
.definitions.issue.properties.type.title "Type" "Issue Type" IssueType
.definitions.patch.properties.type.title "Type" "Patch Type" PatchType
.definitions.releaseNotes.properties.type.title "Type" "Release Type" ReleaseType
.definitions.vulnerabilitySource.title "Source" "Vulnerability Source" VulnerabilitySource

howardj99 avatar Mar 31 '23 17:03 howardj99

some were fixed via https://github.com/CycloneDX/specification/pull/323/commits/a0e58b1837c4b834e8236de603c3b56c0a83af60

jkowalleck avatar Mar 18 '24 13:03 jkowalleck

others were fixed via 60b0e4600c1c95f982d13ad29bc207faac831fdb

jkowalleck avatar Mar 31 '24 13:03 jkowalleck

seams like a lot of the JSON titles were modified during v1.6 development. need to revisit after the release.

jkowalleck avatar Mar 31 '24 13:03 jkowalleck