Replies: 3 comments
-
Looks like some great progress.. I've never used the not operator on a schema? I'm trying to think about a use case where the inclusion of a specific property would cause the validation to fail. for enum JSON schema properties, I would expect it to generate the typescript enum and think link in that type. export enum ResultStatus {
COVERAGE_ACTIVE = 'active',
COVERAGE_NOT_ACTIVE = 'not_active',
UNKNOWN = 'unknown',
} const EligibilityResultSchema = Type.Object({
id: Type.String({ format: 'uuid' }),
person: PersonSchema,
status: Type.Enum(ResultStatus, { default: ResultStatus.UNKNOWN }),
artifacts: Type.Array(ArtifactSchema),
}); {
"title": "ResultsStatus",
"description": "The status of the eligibility result check",
"enum": [
"unknown",
"no_results_found",
"results_obtained",
"error"
],
"type": "string",
"$id": "resultsstatus.json"
}
{
"title": "EligibilityResult",
"type": "object",
"properties": {
"id": {
"title": "Id",
"type": "string",
"format": "uuid4"
},
"person": {
"$ref": "./person.json"
},
"status": {
"$ref": "./resultstatus.json"
},
"artifacts": {
"title": "Artifacts",
"type": "array",
"items": {
"$ref": "./artifact.json"
}
}
},
"required": [
"person",
"status",
"artifacts"
],
"additionalProperties": false,
"$id": "eligibilityresult.json"
}
|
Beta Was this translation helpful? Give feedback.
-
@jamesrusso Nice, thanks for the samples. Implementing enums should be somewhat straight forward now! $ref will be another cup of tea :p Could you create a branch/pr containing some json schemas with refs as well as the typebox code for it? This will certainly help when tackling the $ref property. EDIT: enum type is done, thanks for the examples!. Would be really helpful if you could provide a set of json schemas with refs to other json schemas (one schema referencing 1 or 2 others would be perfect) for the next feature: supporting $ref to JSON schema files. I did release 0.2.0 with the current feature set, if that is of any help for you. |
Beta Was this translation helpful? Give feedback.
-
@jamesrusso Will delay/skip implementing "not" for now. Ignore my previous reply from yesterday. The $ref with relative files went somewhat smoother than expected, happy to hear your feedback on this one. Will close this for now since "enum" was implemented. Thanks for your help! |
Beta Was this translation helpful? Give feedback.
-
@sinclairzx81 @jamesrusso Hey!
I feel like so far it is going pretty well. I created a feature list with the currently implemented features in the readme here. I would be happy about any thoughts/ideas on how to tackle points still left to be implemented.
Especially for
enum
andnot
JSON schema properties.Beta Was this translation helpful? Give feedback.
All reactions