Closed pchainho closed 8 years ago
I'm trying to figure out what should be the new output. For example, picking the message.cduml and one of the genereted files Message.json:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "Message",
"type": "object",
"required": ["id", "from", "type", "contextId", "body", "messageType", "uRL", "messageBodyArray"],
"additionalProperties": false,
"properties": {
"id": {
"type": "string"
},
"from": {
"$ref": "../URL/URL.json"
},
"to": {
"$ref": "../URL/URLList.json"
},
"type": {
"$ref": "../Message/MessageType.json"
},
"contextId": {
"type": "null"
},
"body": {
"$ref": "../Message/MessageBody.json"
},
"signature": {
"type": "null"
}
,
"messageType": {
"$ref": "../Message/MessageType.json"
},
"uRL": {
"$ref": "../URL/URL.json"
},
"messageBodyArray": {
"$ref": "../Message/MessageBody.json"
}
}
}
How should I generate the references? I was trying to use the concept of "definitions" http://spacetelescope.github.io/understanding-json-schema/structuring.html But this requires to define a top level class in the package. This can work in message.cduml if considering the top level class of the same name of the package, but it's not always possible.
Another problem that as came up is related to mismatch between UML definitions and JSON Schema. This is not a technical problem and there's nothing wrong with the actual generated schemas, it's just, they are not as useful as it seems. The way JSON Schema is validated, is starting on a root object and verifies every field and reference attached to it. However class diagrams don't strictly follow a tree structure. Even if we define a root object, if there are detached definitions (with inverted references), these are not validated. JSON schema is directly related to document databases. But class diagramas define better, relational databases. I don't see a way to solve this, unless carefully designing the class diagrams. By following a tree structure and by separating in different packages. Any ideas are wellcome.
Found other minor issues:
ClassX --> ClassY
there is no place to define the reference variable name. The placeolder after the definition could be used like ClassX --> ClassY:name
but this is currently defined as free text (not suitable to a variable name, because it can have spaces).Some proposed solutions:
ClassX --> ClassY
will be the same as ClassX -- ClassY
assuming the left to right direction.
But I would rather prefer that UML be corrected instead.
- Use the PlantUML feature "specific spot" to define custom type elements. Just add <<(T,orchid)>> to the class definition to be a Type definition.
ok
- Use the relation description for variable name, and drop the general purpose.
We agreed to ignore associations like ClassX --> ClassY and to just take into account attributs defined in each class.
- Do not generate inverted references. For example ClassX --> ClassY will be the same as ClassX -- ClassY assuming the left to right direction.
This one should not be an issue anymore since we agreed to ignore plantuml associations
- Should be defined as "field: type[]"
ok
Parser was not prepared to accept relations beetween packages. It's was updated, but no JSON is generated for this.
Parser was updated, and schemas generated.
Not done according to previously agreed structure
partially done according to agreed structure. It is ready to be used for the validation of data synch objects.
Update json-schema generation tool according to new package structure as discussed in #16
json-schema generation tool should be moved to this repo: src/tools