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

add option (checkbox) to apply JSON case rules #130

Open
onthebreeze opened this issue May 26, 2020 · 1 comment
Open

add option (checkbox) to apply JSON case rules #130

onthebreeze opened this issue May 26, 2020 · 1 comment
Assignees

Comments

@onthebreeze
Copy link
Contributor

onthebreeze commented May 26, 2020

When generating OpenAPI3 specs that make developers happy

  • Classes should be Upper Camel Case (eg Application)
  • properties should be Lower Camel Case (eg status property of Application)
  • this includes properties which are associations (eg the association between VisaApplication and TravelCompanion classes should be named travelCompanion)

since models may be imported from other sources (eg UN RDMs) that may have different conventions, it would be a terribly time consuming task to go through 100's of properties to change cases to suit the output. instead these rules should be encoded as NDR (naming and design rules) when generating OpenAPI and JSON-LD:

  • Always change class names to UCC (so remove any spaces / hyphens / undersocres and capitalise the first letter of each word in the class name)
  • always change property names to LCC (so (so remove any spaces / hyphens / undersocres and capitalise the first letter of any words after first in the property name)
  • if a relationship (eg aggregation or composition) has a name then make sure it is changed to LCC like properties
  • if a relationship (eg aggregation or composition) does not have the name then use the name of the target class but make sure to make it LCC (as target class will be UCC). In this way the relationship will appear as a LCC property of the source class.

In most cases the modeler will want to apply these rules but in some cases the modeller may prefer to use names excactly as in the model. therefore this should be a configurable option - as a checkbox (default checked) to apply JSON NDR.

@onthebreeze
Copy link
Contributor Author

and similarly for core data types

  • Identifier -> JSON string, format = uri
  • Code -> JSON string
  • DateTime -> JSON string, format = date-time
  • Date -> JSON string, format = date
  • Time -> JSON string, format = time
  • Numeric -> number
  • Text -> string
  • Indicator -> boolean

Then there's the composite ones which we can setup as objects with attributes - so the mapping to simple JSON type is at the property of data type level rather than property of RDM class level.

  • Amount should be modelled as a class with value (numeric) and currency (string) properties
  • Measure should be modelled as a class with value (numeric) and uom (string) properties

And then there's the non-text binary types which should probably map to JSON contentMedia type like

{
"type": "string",
"contentEncoding": "base64",
"contentMediaType": "image/png"
}

kshychko added a commit that referenced this issue May 26, 2020
kshychko added a commit that referenced this issue May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants