-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for json schema oneOf enumStrategy (#2504)
This adds support for a new json schema setting, `enumStrategy`, that allows for variants `enum` (current behaviour, and default) and `oneOf` (gets converted to a oneOf with const string values, allowing for documentation of individual enum variants.)
- Loading branch information
Showing
6 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
.../test/resources/software/amazon/smithy/jsonschema/string-enums-one-of.jsonschema.v07.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"definitions": { | ||
"Foo": { | ||
"type": "object", | ||
"properties": { | ||
"bar": { | ||
"$ref": "#/definitions/TestEnum" | ||
} | ||
} | ||
}, | ||
"TestEnum": { | ||
"type": "string", | ||
"description": "This is a test enum", | ||
"oneOf": [ | ||
{ | ||
"const": "Foo", | ||
"description": "it really does foo" | ||
}, | ||
{ | ||
"const": "Bar" | ||
} | ||
] | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ema/src/test/resources/software/amazon/smithy/jsonschema/string-enums.jsonschema.v07.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"definitions": { | ||
"Foo": { | ||
"type": "object", | ||
"properties": { | ||
"bar": { | ||
"$ref": "#/definitions/TestEnum" | ||
} | ||
} | ||
}, | ||
"TestEnum": { | ||
"type": "string", | ||
"enum": [ | ||
"Foo", | ||
"Bar" | ||
], | ||
"description": "This is a test enum" | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
smithy-jsonschema/src/test/resources/software/amazon/smithy/jsonschema/string-enums.smithy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
$version: "2.0" | ||
|
||
namespace smithy.example | ||
|
||
structure Foo { | ||
bar: TestEnum | ||
} | ||
|
||
@documentation("This is a test enum") | ||
enum TestEnum { | ||
@documentation("it really does foo") | ||
FOO = "Foo" | ||
BAR = "Bar" | ||
} |