Skip to content

Commit 3d2b3d4

Browse files
apply the ABNF for header names at rfc9110 §5.1
..and the same pattern applies to HTTP method names too
1 parent f48f3b6 commit 3d2b3d4

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

src/schemas/validation/schema.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ $defs:
243243
$ref: '#/$defs/operation'
244244
propertyNames:
245245
$comment: RFC9110 restricts methods to "1*tchar" in ABNF
246-
pattern: "^[a-zA-Z0-9!#$%&'*+.^_`|~-]+$"
246+
$ref: '#/$defs/token'
247247
not:
248248
enum:
249249
- GET
@@ -414,6 +414,14 @@ $defs:
414414
then:
415415
required:
416416
- content
417+
- if:
418+
properties:
419+
in:
420+
const: header
421+
then:
422+
properties:
423+
name:
424+
$ref: '#/$defs/token'
417425
dependentSchemas:
418426
schema:
419427
properties:
@@ -604,6 +612,8 @@ $defs:
604612
format: media-range
605613
headers:
606614
type: object
615+
propertyNames:
616+
$ref: '#/$defs/token'
607617
additionalProperties:
608618
$ref: '#/$defs/header-or-reference'
609619
style:
@@ -679,6 +689,8 @@ $defs:
679689
type: string
680690
headers:
681691
type: object
692+
propertyNames:
693+
$ref: '#/$defs/token'
682694
additionalProperties:
683695
$ref: '#/$defs/header-or-reference'
684696
content:
@@ -1149,3 +1161,8 @@ $defs:
11491161
properties:
11501162
explode:
11511163
default: false
1164+
1165+
token:
1166+
$comment: see https://www.rfc-editor.org/rfc/rfc9110.html#section-5.6.2
1167+
type: string
1168+
pattern: '^[0-9A-Za-z!#$%&\'*+.^_`|~-]+$'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
openapi: 3.3.0
2+
info:
3+
title: the header name, as used in serialization, has a constrained syntax
4+
version: 1.0.0
5+
paths:
6+
/foo:
7+
get:
8+
responses:
9+
default:
10+
headers:
11+
'Bad=Header':
12+
schema: {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
openapi: 3.3.0
2+
info:
3+
title: header name has a constrained syntax
4+
version: 1.0.0
5+
components:
6+
parameters:
7+
BadHeader:
8+
name: 'Bad[Header]'
9+
in: header
10+
schema: {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
openapi: 3.2.0
2+
info:
3+
title: header name has a constrained syntax, but the component name is not the header name
4+
version: 1.0.0
5+
components:
6+
headers:
7+
'Still=Legal':
8+
schema: {}

0 commit comments

Comments
 (0)