Skip to content

[Schema] TypeScript to JSON Schema #786

@kjdelisle

Description

@kjdelisle

Story

As a LB4 dev, I want my TypeScript classes to be automatically converted into JSON Schema so that I have a metadata representation of my classes that I can freely convert into other formats (OpenAPI schema, other classes in other languages, etc)

Cross-posting from #700:

In our Todo model example, we are duplicating information about model properties - first time in Model definition, second time in Swagger (OpenAPI) Schema.

We should have a helper function that can create Swagger/OpenAPI Schema from the Model data.

Acceptance Criteria

  • Create a metadata type system (yikes!) that leverages the existing decorator names (@model, @property)
  • For @property:
    • Introspect the type of the property, either as a primitive type, or otherwise
      • For complex types, mark with $ref (we can dereference this later)
  • For @model:
    • Add top-level specific metadata to the entry for this type:
      • description
      • title
      • required
      • oneOf (it's a union type!) not supported by current juggler implementation
  • Write a blog post about how awesome this will be (unless it's not, then don't ;) )
  • Document on loopback.io

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions