encoding/openapi: add Info and DescriptorFunc features
Two settings added to Generator:
- Info adds the OpenAPI info section.
- DescriptorFunc allows for custom descriptions, given
a value.
If the All API is used, an empty info section will be added
if the user hasn't given any. This is to reflect the fact
that info.version and info.title are required.
Issue #56
Change-Id: Ief29b40bf6be9c8026052588f6de9fb06d41095f
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2442
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/encoding/openapi/testdata/oneof-funcs.json b/encoding/openapi/testdata/oneof-funcs.json
new file mode 100644
index 0000000..2ca742f
--- /dev/null
+++ b/encoding/openapi/testdata/oneof-funcs.json
@@ -0,0 +1,70 @@
+{
+ "openapi": "3.0.0",
+ "info": {
+ "title": "test",
+ "version": "v1"
+ },
+ "components": {
+ "schema": {
+ "MYSTRING": {
+ "description": "Randomly picked description from a set of size one.",
+ "oneOf": [
+ {
+ "type": "object",
+ "required": [
+ "exact"
+ ],
+ "properties": {
+ "exact": {
+ "description": "Randomly picked description from a set of size one.",
+ "type": "string",
+ "format": "string"
+ }
+ }
+ },
+ {
+ "type": "object",
+ "required": [
+ "regex"
+ ],
+ "properties": {
+ "regex": {
+ "description": "Randomly picked description from a set of size one.",
+ "type": "string",
+ "format": "string"
+ }
+ }
+ }
+ ]
+ },
+ "MYINT": {
+ "description": "Randomly picked description from a set of size one.",
+ "type": "integer"
+ },
+ "FOO": {
+ "description": "Randomly picked description from a set of size one.",
+ "type": "object",
+ "required": [
+ "include",
+ "exclude",
+ "count"
+ ],
+ "properties": {
+ "count": {
+ "$ref": "#/components/schema/MYINT"
+ },
+ "exclude": {
+ "description": "Randomly picked description from a set of size one.",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schema/MYSTRING"
+ }
+ },
+ "include": {
+ "$ref": "#/components/schema/MYSTRING"
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file