Skip to content

Commit 9d3e946

Browse files
authored
Merge pull request #1454 from jstoiko/patch-1
Fixed some invalid examples
2 parents c0290d2 + 0a66966 commit 9d3e946

File tree

1 file changed

+75
-46
lines changed

1 file changed

+75
-46
lines changed

versions/3.0.2.md

+75-46
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,18 @@ my.org.User
472472
```json
473473
"components": {
474474
"schemas": {
475+
"GeneralError": {
476+
"type": "object",
477+
"properties": {
478+
"code": {
479+
"type": "integer",
480+
"format": "int32"
481+
},
482+
"message": {
483+
"type": "string"
484+
}
485+
}
486+
},
475487
"Category": {
476488
"type": "object",
477489
"properties": {
@@ -562,6 +574,14 @@ my.org.User
562574
```yaml
563575
components:
564576
schemas:
577+
GeneralError:
578+
type: object
579+
properties:
580+
code:
581+
type: integer
582+
format: int32
583+
message:
584+
type: string
565585
Category:
566586
type: object
567587
properties:
@@ -1903,65 +1923,74 @@ In all cases, the example value is expected to be compatible with the type schem
19031923
of its associated value. Tooling implementations MAY choose to
19041924
validate compatibility automatically, and reject the example value(s) if incompatible.
19051925

1906-
##### Example Object Example
1926+
##### Example Object Examples
1927+
1928+
In a model:
19071929

19081930
```yaml
1909-
# in a model
19101931
schemas:
19111932
properties:
19121933
name:
19131934
type: string
19141935
examples:
19151936
name:
19161937
$ref: http://example.org/petapi-examples/openapi.json#/components/examples/name-example
1938+
```
19171939

1918-
# in a request body:
1919-
requestBody:
1920-
content:
1921-
'application/json':
1922-
schema:
1923-
$ref: '#/components/schemas/Address'
1924-
examples:
1925-
foo:
1926-
summary: A foo example
1927-
value: {"foo": "bar"}
1928-
bar:
1929-
summary: A bar example
1930-
value: {"bar": "baz"}
1931-
'application/xml':
1932-
examples:
1933-
xmlExample:
1934-
summary: This is an example in XML
1935-
externalValue: 'http://example.org/examples/address-example.xml'
1936-
'text/plain':
1937-
examples:
1938-
textExample:
1939-
summary: This is a text example
1940-
externalValue: 'http://foo.bar/examples/address-example.txt'
1941-
1940+
In a request body:
19421941

1943-
# in a parameter
1944-
parameters:
1945-
- name: 'zipCode'
1946-
in: 'query'
1942+
```yaml
1943+
requestBody:
1944+
content:
1945+
'application/json':
19471946
schema:
1948-
type: 'string'
1949-
format: 'zip-code'
1950-
examples:
1951-
zip-example:
1952-
$ref: '#/components/examples/zip-example'
1947+
$ref: '#/components/schemas/Address'
1948+
examples:
1949+
foo:
1950+
summary: A foo example
1951+
value: {"foo": "bar"}
1952+
bar:
1953+
summary: A bar example
1954+
value: {"bar": "baz"}
1955+
'application/xml':
1956+
examples:
1957+
xmlExample:
1958+
summary: This is an example in XML
1959+
externalValue: 'http://example.org/examples/address-example.xml'
1960+
'text/plain':
1961+
examples:
1962+
textExample:
1963+
summary: This is a text example
1964+
externalValue: 'http://foo.bar/examples/address-example.txt'
1965+
```
19531966

1954-
# in a response
1955-
responses:
1956-
'200':
1957-
description: your car appointment has been booked
1958-
content:
1959-
application/json:
1960-
schema:
1961-
$ref: '#/components/schemas/SuccessResponse'
1962-
examples:
1963-
confirmation-success:
1964-
$ref: '#/components/examples/confirmation-success'
1967+
In a parameter:
1968+
1969+
```yaml
1970+
parameters:
1971+
- name: 'zipCode'
1972+
in: 'query'
1973+
schema:
1974+
type: 'string'
1975+
format: 'zip-code'
1976+
examples:
1977+
zip-example:
1978+
$ref: '#/components/examples/zip-example'
1979+
```
1980+
1981+
In a response:
1982+
1983+
```yaml
1984+
responses:
1985+
'200':
1986+
description: your car appointment has been booked
1987+
content:
1988+
application/json:
1989+
schema:
1990+
$ref: '#/components/schemas/SuccessResponse'
1991+
examples:
1992+
confirmation-success:
1993+
$ref: '#/components/examples/confirmation-success'
19651994
```
19661995

19671996

0 commit comments

Comments
 (0)