Skip to content

Commit c25ddac

Browse files
authored
fix(vadliation): example property (#10)
* fix(vadliation): example property fix #9 * docs(github): add playground url in bug report
1 parent 9b3db50 commit c25ddac

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

.github/ISSUE_TEMPLATE/BUG_REPORT.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ labels: "Status: Unconfirmed"
1414
-->
1515

1616
<!--
17-
Write the minimum OpenAPI JSON or YAML Schema needed to reproduce the bug.
17+
Write the minimum OpenAPI JSON or YAML Schema needed to reproduce the bug.
18+
If you can reproduce it with the following Playground, please post the URL too.
19+
https://himenon.github.io/openapi-typescript-code-generator-playground/index.html
1820
-->
1921

2022
## The current behavior

scripts/testCodeGen.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const main = () => {
77
entryPoint: "test/api.test.domain/index.yml",
88
log: {
99
validator: {
10-
displayLogLines: 3,
10+
displayLogLines: 1,
1111
},
1212
},
1313
};

src/Validator/v3/openapi.json

+20-1
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,26 @@
719719
"$ref": "#/definitions/externalDocs"
720720
},
721721
"example": {
722-
"$ref": "#/definitions/any"
722+
"oneOf": [
723+
{
724+
"type": "null"
725+
},
726+
{
727+
"type": "number"
728+
},
729+
{
730+
"type": "boolean"
731+
},
732+
{
733+
"type": "string"
734+
},
735+
{
736+
"type": "object"
737+
},
738+
{
739+
"type": "array"
740+
}
741+
]
723742
},
724743
"deprecated": {
725744
"type": "boolean"

test/api.test.domain/index.yml

+16
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ components:
2020
StringType:
2121
type: string
2222
description: String Literal
23+
example: "string-type"
2324
StringHasEnumType:
2425
type: string
2526
enum: [a, A, b, B, c, C]
27+
example: "a"
2628
StringDateType:
2729
type: string
2830
format: date
@@ -47,15 +49,19 @@ components:
4749
NumberHasEnumType:
4850
type: number
4951
enum: [1, 2, 3, 100, 123, 0.1, -0.1, 0.0]
52+
example: -0.1
5053
NumberInt32Type:
5154
type: number
5255
format: int32
56+
example: 12
5357
NumberInt64Type:
5458
type: number
5559
format: int64
60+
example: 64
5661
NumberFloat:
5762
type: number
5863
format: float
64+
example: 3.141592
5965
NumberDouble:
6066
type: number
6167
format: double
@@ -70,10 +76,12 @@ components:
7076
type: array
7177
items:
7278
type: number
79+
example: [1, 2, 3]
7380
ArrayBooleanType:
7481
type: array
7582
items:
7683
type: boolean
84+
example: [true, false, true]
7785
ObjectEmptyPropertiesType:
7886
type: object
7987
ObjectHasPropertiesType:
@@ -94,6 +102,14 @@ components:
94102
properties:
95103
requiredStringType:
96104
type: string
105+
example:
106+
{
107+
"stringType": "string-type",
108+
"numberType": 1,
109+
"booleanType": false,
110+
"arrayType": [],
111+
"objectType": { "requiredStringType": "required-string-type" },
112+
}
97113
OneOfType:
98114
oneOf:
99115
- type: string

0 commit comments

Comments
 (0)