Closed andrew-farries closed 4 months ago
Attention: Patch coverage is 66.66667%
with 1 lines
in your changes are missing coverage. Please review.
Project coverage is 75.94%. Comparing base (
d963216
) to head (27032aa
). Report is 21 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
pkg/generator/schema_generator.go | 50.00% | 1 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Allow
CustomNameType
s to specify their nillability.Currently
CustomNameType
s are hard-coded to haveIsNillable
returnfalse
. This limitation means that fields in an object having a custom type are always wrapped in a pointer type when they are not required fields. For example:This results in the following Go code:
The
map[bool]string
is nillable, butgo-jsonschema
's schema generation generates a pointer type for thename
field.By extending the
GoJSONSchemaExtension
type with an extraNillable
field, custom types can specify their nillability in order to ensure they aren't wrapped in a pointer type when such fields are optional.The motivation for this change is to be able to use the nullable package to distinguish between set-to-null fields and missing fields.
This snippet:
Should generate a
name
field of typenullable.Nullable[string]
rather than*nullable.Nullable[string]
, in line with the documentation fornullable
which advises against using pointers to the type.