Skip to content

Commit

Permalink
Refactor json schema, to allow single type values, or lists if necessary
Browse files Browse the repository at this point in the history
remove schemaTypeFor from OpenAPIDocument

decomposition of structs
  • Loading branch information
peschmae committed Apr 11, 2024
1 parent 8b7982f commit 1994def
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 119 deletions.
153 changes: 51 additions & 102 deletions pkg/cmd/template/schema_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1079,59 +1079,46 @@ foo:
expected := `$schema: https://json-schema.org/draft/2020-12/schema
$id: https://example.biz/schema/ytt/data-values.json
description: Schema for data values, generated by ytt
type:
- object
type: object
additionalProperties: false
properties:
foo:
type:
- object
type: object
additionalProperties: false
properties:
int_key:
type:
- integer
type: integer
default: 10
bool_key:
type:
- boolean
type: boolean
default: true
false_key:
type:
- boolean
type: boolean
default: false
string_key:
type:
- string
type: string
default: some text
float_key:
type:
- number
type: number
format: float
default: 9.1
array_of_scalars:
type:
- array
type: array
items:
type:
- string
type: string
default: ""
default: []
array_of_maps:
type:
- array
type: array
items:
type:
- object
type: object
additionalProperties: false
properties:
foo:
type:
- string
type: string
default: ""
bar:
type:
- string
type: string
default: ""
default: []
`
Expand Down Expand Up @@ -1170,62 +1157,49 @@ foo:
expected := `$schema: https://json-schema.org/draft/2020-12/schema
$id: https://example.biz/schema/ytt/data-values.json
description: Schema for data values, generated by ytt
type:
- object
type: object
additionalProperties: false
properties:
foo:
type:
- object
type: object
additionalProperties: false
properties:
int_key:
type:
- integer
type: integer
default: 10
bool_key:
type:
- boolean
type: boolean
default: true
false_key:
type:
- boolean
type: boolean
default: false
string_key:
type:
- string
type: string
default: some text
float_key:
type:
- number
type: number
format: float
default: 9.1
array_of_scalars:
type:
- array
type: array
items:
type:
- integer
type: integer
default: 0
default:
- 1
- 2
- 3
array_of_maps:
type:
- array
type: array
items:
type:
- object
type: object
additionalProperties: false
properties:
bar:
type:
- string
type: string
default: ""
ree:
type:
- string
type: string
default: default
default:
- bar: thing 1
Expand Down Expand Up @@ -1274,13 +1248,11 @@ foo:
expected := `$schema: https://json-schema.org/draft/2020-12/schema
$id: https://example.biz/schema/ytt/data-values.json
description: Schema for data values, generated by ytt
type:
- object
type: object
additionalProperties: false
properties:
foo:
type:
- object
type: object
additionalProperties: false
properties:
int_key:
Expand Down Expand Up @@ -1314,17 +1286,15 @@ properties:
- array
- "null"
items:
type:
- integer
type: integer
default: 0
default: null
array_of_maps:
type:
- array
- "null"
items:
type:
- object
type: object
additionalProperties: false
properties:
bar:
Expand Down Expand Up @@ -1407,8 +1377,7 @@ foo:
expected := `$schema: https://json-schema.org/draft/2020-12/schema
$id: https://example.biz/schema/ytt/data-values.json
description: Schema for data values, generated by ytt
type:
- object
type: object
additionalProperties: false
properties:
foo:
Expand Down Expand Up @@ -1452,22 +1421,18 @@ foo:
expected := `$schema: https://json-schema.org/draft/2020-12/schema
$id: https://example.biz/schema/ytt/data-values.json
description: Schema for data values, generated by ytt
type:
- object
type: object
additionalProperties: false
properties:
foo:
type:
- object
type: object
additionalProperties: false
properties:
int_key:
type:
- integer
type: integer
default: 0
array_of_scalars:
type:
- array
type: array
items:
type:
- "null"
Expand All @@ -1479,20 +1444,16 @@ properties:
default: ""
default: []
array_of_maps:
type:
- array
type: array
items:
type:
- object
type: object
additionalProperties: false
properties:
foo:
type:
- string
type: string
default: ""
bar:
type:
- string
type: string
default: ""
default: []
`
Expand Down Expand Up @@ -1548,13 +1509,11 @@ foo:
expected := `$schema: https://json-schema.org/draft/2020-12/schema
$id: https://example.biz/schema/ytt/data-values.json
description: Schema for data values, generated by ytt
type:
- object
type: object
additionalProperties: false
properties:
foo:
type:
- object
type: object
additionalProperties: false
properties:
int_key:
Expand Down Expand Up @@ -1588,8 +1547,7 @@ properties:
- array
- "null"
items:
type:
- integer
type: integer
default: 0
default:
- 1
Expand All @@ -1600,8 +1558,7 @@ properties:
- array
- "null"
items:
type:
- object
type: object
additionalProperties: false
properties:
bar:
Expand Down Expand Up @@ -1661,48 +1618,40 @@ foo:
expected := `$schema: https://json-schema.org/draft/2020-12/schema
$id: https://example.biz/schema/ytt/data-values.json
description: Schema for data values, generated by ytt
type:
- object
type: object
additionalProperties: false
properties:
foo:
type:
- object
type: object
additionalProperties: false
properties:
range_key:
type:
- integer
type: integer
default: 10
minimum: 0
maximum: 100
min_key:
type:
- integer
type: integer
default: 10
minimum: 0
max_key:
type:
- integer
type: integer
default: 10
maximum: 100
string_key:
type:
- string
type: string
default: ""
minLength: 1
maxLength: 10
one_of_integers:
type:
- integer
type: integer
default: 1
enum:
- 1
- 2
- 3
one_of_strings:
type:
- string
type: string
default: one
enum:
- one
Expand Down
Loading

0 comments on commit 1994def

Please sign in to comment.