swagger_to_uml icon indicating copy to clipboard operation
swagger_to_uml copied to clipboard

Resolve relations to referenced resources when references follow a na…

Open phfeustel opened this issue 6 years ago • 0 comments

…ming convention.

Example: A theater play has serveral character roles. When creating or updating a role resource I want to include the back reference from role to play also in the payload. But I don't want to send the whole play payload. To model this relation I set the playResourceId within the role resource. I want this relation to be reflected also in my UML diagrams but cannot $ref the play resource in role because this would include the complete play resource JSON in role. That's why I just use the playResourceId.

To be able to reflect this relationship in the UML I propose to search for ResouceId in the format string endings of the referencing resource. If found, a relation between the referencing and the referenced resource (role and play) in this case is created.

  Play:
    type: object
    properties:
      id:
        type: string
        format: uuid
      title:
        type: string
  Role:
    type: object
    properties:
      id:
        type: string
        format: uuid
      title:
        type: string
      playId:
        type: string
        format: playResourceId

Creates:

class Play {
    {field} string (uuid) id
    {field} string title
}
class Role {
    {field} string (uuid) id
    {field} string title
    {field} string (playResourceId) playId
}

Role ..> Play

phfeustel avatar Apr 26 '18 16:04 phfeustel