add some more todos:

This commit is contained in:
Shreyas Goenka 2024-08-20 15:39:31 +02:00
parent 75f252e51c
commit 43325fdd0a
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
2 changed files with 8 additions and 6 deletions

View File

@ -50,7 +50,8 @@ func New(golangType reflect.Type, docs *Docs) (*jsonschema.Schema, error) {
s, s,
{ {
Type: jsonschema.StringType, Type: jsonschema.StringType,
// TODO: // TODO: Narrow down the scope of the regex match.
// Also likely need to rename this variable.
Pattern: dynvar.VariableRegex, Pattern: dynvar.VariableRegex,
}, },
}, },

View File

@ -62,11 +62,10 @@ func FromType(typ reflect.Type, opts FromTypeOptions) (Schema, error) {
res = Schema{Type: StringType} res = Schema{Type: StringType}
case reflect.Bool: case reflect.Bool:
res = Schema{Type: BooleanType} res = Schema{Type: BooleanType}
// case reflect.Int, reflect.Int32, reflect.Int64: // TODO: Add comment about reduced coverage of primitive Go types in the code paths here.
// res = Schema{Type: IntegerType} case reflect.Int:
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, res = Schema{Type: IntegerType}
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, case reflect.Float32, reflect.Float64:
reflect.Float32, reflect.Float64:
res = Schema{Type: NumberType} res = Schema{Type: NumberType}
default: default:
return InvalidSchema, fmt.Errorf("unsupported type: %s", typ.Kind()) return InvalidSchema, fmt.Errorf("unsupported type: %s", typ.Kind())
@ -164,6 +163,8 @@ func fromTypeStruct(typ reflect.Type, opts FromTypeOptions) (Schema, error) {
return res, nil return res, nil
} }
// TODO: Add comments explaining the translation between struct, map, slice and
// the JSON schema representation.
func fromTypeSlice(typ reflect.Type, opts FromTypeOptions) (Schema, error) { func fromTypeSlice(typ reflect.Type, opts FromTypeOptions) (Schema, error) {
if typ.Kind() != reflect.Slice { if typ.Kind() != reflect.Slice {
return InvalidSchema, fmt.Errorf("expected slice, got %s", typ.Kind()) return InvalidSchema, fmt.Errorf("expected slice, got %s", typ.Kind())