Skip to content

Commit abf38fc

Browse files
authored
Merge pull request #109 from jmespath-community/feature/function-schema
Made YAML version of JSON schema more idiomatic.
2 parents bfc92f9 + 4f6b907 commit abf38fc

File tree

1 file changed

+131
-66
lines changed

1 file changed

+131
-66
lines changed

function_schema.yml

Lines changed: 131 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
$schema: https://json-schema.org/draft/2020-12/schema
3-
$id: https://jmespath.site/function_schema.yml
2+
$schema: 'https://json-schema.org/draft/2020-12/schema'
3+
$id: 'https://jmespath.site/function_schema.yml'
44
title: JMESPath function
55
description: JMESPath function definition and tests
66
$defs:
@@ -35,85 +35,150 @@ $defs:
3535
type: string
3636
description: ""
3737
type: object
38-
required: [name, topic, args, returns, desc, examples]
38+
required:
39+
- name
40+
- topic
41+
- args
42+
- returns
43+
- desc
44+
- examples
3945
properties:
4046
name:
4147
type: string
4248
description: function identifier
4349
topic:
44-
enum: [math, strings, collections, conversion, misc]
50+
$ref: '#/definitions/topics'
4551
description: related function topic
4652
args:
4753
type: object
4854
additionalProperties: false
4955
properties:
50-
required: &arg
51-
type: array
52-
description: ""
53-
items:
54-
allOf:
55-
- $ref: "#/$defs/unnamed_arg"
56-
- type: object
57-
required:
58-
- name
59-
properties:
60-
name:
61-
type: string
62-
description: ""
63-
description: ""
64-
unevaluatedProperties: false
65-
optional: *arg
66-
variadic: *unnamed_arg
56+
required:
57+
$ref: '#/definitions/arguments'
58+
description: required function arguments
59+
optional:
60+
$ref: '#/definitions/arguments'
61+
description: optional function arguments
62+
variadic:
63+
$ref: '#/definitions/signature'
64+
description: variadic arguments type
6765
returns:
68-
type: object
69-
description: ""
70-
required: [type, desc]
71-
additionalProperties: false
72-
properties:
73-
type:
74-
<<: *type
75-
description: ""
76-
desc:
77-
type: string
78-
description: ""
66+
$ref: '#/definitions/returnValue'
67+
description: function return type
7968
desc:
8069
type: string
81-
description: ""
70+
description: description
8271
examples:
72+
$ref: '#/definitions/example'
73+
definitions:
74+
argument:
75+
allOf:
76+
- $ref: '#/definitions/signature'
77+
- type: object
78+
required:
79+
- name
80+
properties:
81+
name:
82+
type: string
83+
unevaluatedProperties: false
84+
arguments:
85+
type: array
86+
items:
87+
$ref: '#/definitions/argument'
88+
dataTypes:
89+
type: string
90+
enum:
91+
- any
92+
- number
93+
- string
94+
- boolean
95+
- array
96+
- object
97+
- 'null'
98+
- expression
99+
- 'array[number]'
100+
- 'array[string]'
101+
- 'array[boolean]'
102+
- 'array[object]'
103+
- 'array[any]'
104+
- 'array[array[any]]'
105+
- expression->any
106+
- expression->number
107+
- expression->string
108+
errors:
109+
type: string
110+
enum:
111+
- invalid-arity
112+
- invalid-type
113+
- not-a-number
114+
- syntax
115+
- unknown-function
116+
example:
83117
type: object
84-
description: ""
85-
additionalProperties: false
118+
description: example
86119
minProperties: 1
87120
patternProperties:
88-
"^\\w.*$":
89-
description: ""
121+
^\w.*$:
122+
description: example
123+
oneOf:
124+
- $ref: '#/definitions/exampleFailure'
125+
- $ref: '#/definitions/exampleSuccess'
126+
unevaluatedProperties: false
127+
exampleInput:
128+
type: object
129+
required:
130+
- args
131+
- context
132+
properties:
133+
context:
134+
description: given input JSON document
135+
args:
136+
type: array
137+
description: function arguments
138+
items:
139+
description: ''
140+
comment:
141+
description: comment
142+
exampleFailure:
143+
allOf:
144+
- $ref: '#/definitions/exampleInput'
145+
- type: object
146+
required:
147+
- error
148+
properties:
149+
error:
150+
$ref: '#/definitions/errors'
151+
exampleSuccess:
152+
allOf:
153+
- $ref: '#/definitions/exampleInput'
154+
- type: object
155+
required:
156+
- returns
157+
properties:
158+
returns: {}
159+
returnValue:
160+
$ref: '#/definitions/signature'
161+
unevaluatedProperties: false
162+
signature:
163+
type: object
164+
required:
165+
- type
166+
properties:
167+
type:
168+
description: ''
90169
oneOf:
91-
- type: object
92-
required: [context, args, returns]
93-
additionalProperties: false
94-
properties:
95-
context: &context
96-
type: &any ["number","string","boolean","object","array","null"]
97-
description: ""
98-
args: &args
99-
type: array
100-
description: ""
101-
items:
102-
type: *any
103-
description: ""
104-
returns:
105-
type: *any
106-
description: ""
107-
comment: &comment
108-
type: string
109-
description: ""
110-
- type: object
111-
required: [context, args, error]
112-
additionalProperties: false
113-
properties:
114-
context: *context
115-
args: *args
116-
error:
117-
type: string
118-
description: ""
119-
comment: *comment
170+
- $ref: '#/definitions/dataTypes'
171+
- type: array
172+
items:
173+
$ref: '#/definitions/dataTypes'
174+
desc:
175+
type: string
176+
description: ''
177+
topics:
178+
type: string
179+
enum:
180+
- math
181+
- strings
182+
- collections
183+
- conversion
184+
- misc

0 commit comments

Comments
 (0)