Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring the bindgen with the goal of having a simpler IR-like form that makes recursively generating types and code easier. The end goal is to remove all the hairy type portions of the XTP Schema document. e.g.: * type * format * items * $ref * additionalProperties and replace with a recursively defined type `XtpNormalizedSchema` (name will likely change to XtpType). I've kept things backwards compatible by only adding this type on the property `xtpType`. We should switch bindgens to use this object then we can remove the other properties. I also decided to change a little bit about the whole process. e.g.: * moved validation to the parser level code * remove circularReference detection and blocking * added some more tests In order to think more clearly about the whole process, I took up a moment to write up what I think the whole flow for schemas should be in terms of validating and compiling: First we validate against JSON schema. This should ensure that we can parse the document into typescript types in the next step. It should not allow any extra values or any values outside of the enum ranges. We should be able to do a simple `const doc = rawDoc as V1Schema` in typescript and the doc object should be valid. Here we parse the json or yaml into a raw javascript object and cast it to the V1 or V0 schema type. This gives us a raw, but typed representation of the schema. Here we should do extra conditional validation steps that can’t be done (or are too complex to be done) in the JSON Schema. e.g. validating content-type / type pairs, etc. Here we take the raw parsed types and “normalize” them into a simpler form. We will walk the document and replace all occurrences of $ref, items, additionalProperties, type, and format with a single recursive XtpType.
- Loading branch information