From c25ddac5b6a5b3b1baa12c376289cb9858c256ac Mon Sep 17 00:00:00 2001 From: "K.Himeno" Date: Sat, 16 Jan 2021 10:56:59 +0900 Subject: [PATCH] fix(vadliation): example property (#10) * fix(vadliation): example property fix #9 * docs(github): add playground url in bug report --- .github/ISSUE_TEMPLATE/BUG_REPORT.md | 4 +++- scripts/testCodeGen.ts | 2 +- src/Validator/v3/openapi.json | 21 ++++++++++++++++++++- test/api.test.domain/index.yml | 16 ++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md index 62334a84..1c80e564 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.md +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.md @@ -14,7 +14,9 @@ labels: "Status: Unconfirmed" --> ## The current behavior diff --git a/scripts/testCodeGen.ts b/scripts/testCodeGen.ts index 361c3f44..e6efe74b 100644 --- a/scripts/testCodeGen.ts +++ b/scripts/testCodeGen.ts @@ -7,7 +7,7 @@ const main = () => { entryPoint: "test/api.test.domain/index.yml", log: { validator: { - displayLogLines: 3, + displayLogLines: 1, }, }, }; diff --git a/src/Validator/v3/openapi.json b/src/Validator/v3/openapi.json index 8cd1c2c9..01dbdc66 100644 --- a/src/Validator/v3/openapi.json +++ b/src/Validator/v3/openapi.json @@ -719,7 +719,26 @@ "$ref": "#/definitions/externalDocs" }, "example": { - "$ref": "#/definitions/any" + "oneOf": [ + { + "type": "null" + }, + { + "type": "number" + }, + { + "type": "boolean" + }, + { + "type": "string" + }, + { + "type": "object" + }, + { + "type": "array" + } + ] }, "deprecated": { "type": "boolean" diff --git a/test/api.test.domain/index.yml b/test/api.test.domain/index.yml index 9c901409..944d329a 100644 --- a/test/api.test.domain/index.yml +++ b/test/api.test.domain/index.yml @@ -20,9 +20,11 @@ components: StringType: type: string description: String Literal + example: "string-type" StringHasEnumType: type: string enum: [a, A, b, B, c, C] + example: "a" StringDateType: type: string format: date @@ -47,15 +49,19 @@ components: NumberHasEnumType: type: number enum: [1, 2, 3, 100, 123, 0.1, -0.1, 0.0] + example: -0.1 NumberInt32Type: type: number format: int32 + example: 12 NumberInt64Type: type: number format: int64 + example: 64 NumberFloat: type: number format: float + example: 3.141592 NumberDouble: type: number format: double @@ -70,10 +76,12 @@ components: type: array items: type: number + example: [1, 2, 3] ArrayBooleanType: type: array items: type: boolean + example: [true, false, true] ObjectEmptyPropertiesType: type: object ObjectHasPropertiesType: @@ -94,6 +102,14 @@ components: properties: requiredStringType: type: string + example: + { + "stringType": "string-type", + "numberType": 1, + "booleanType": false, + "arrayType": [], + "objectType": { "requiredStringType": "required-string-type" }, + } OneOfType: oneOf: - type: string