Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preserve comments when updating yaml #2327

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions projects/openapi-io/src/write/yaml-roundtrip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,3 @@ function insert<T>(arr: T[], index: number, item: any) {
copy.splice(index, 0, item);
return copy;
}

function remove<T>(arr: T[], index: number) {
const copy = [...arr];
copy.splice(index, 1);
return copy;
}
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ paths:
$ref: "#/components/schemas/GetAuthHawk200ResponseBody"
/basic-auth:
get:
responses: {}
responses:
{}
/cookies/{cooky}:
parameters:
- in: path
Expand All @@ -312,13 +313,16 @@ paths:
schema:
type: string
get:
responses: {}
responses:
{}
/cookies:
get:
responses: {}
responses:
{}
/deflate:
get:
responses: {}
responses:
{}
/delay/{delay}:
parameters:
- in: path
Expand All @@ -336,18 +340,21 @@ paths:
$ref: "#/components/schemas/GetDelayDelay200ResponseBody"
/delete:
delete:
responses: {}
responses:
{}
requestBody:
content:
text/plain:
schema:
type: string
/digest-auth:
get:
responses: {}
responses:
{}
/encoding/utf8:
get:
responses: {}
responses:
{}
/:
get:
responses:
Expand All @@ -359,7 +366,8 @@ paths:
$ref: "#/components/schemas/Get200ResponseBody"
/get/hello:
get:
responses: {}
responses:
{}
/get:
get:
responses:
Expand All @@ -371,7 +379,8 @@ paths:
$ref: "#/components/schemas/GetGet200ResponseBody"
/gzip:
get:
responses: {}
responses:
{}
/headers:
get:
responses:
Expand All @@ -383,33 +392,36 @@ paths:
$ref: "#/components/schemas/GetHeaders200ResponseBody"
/ip:
get:
responses: {}
responses:
{}
/oauth1:
get:
responses:
"200":
description: 200 response
content:
application/json:
schema:
$ref: "#/components/schemas/GetAuthHawk200ResponseBody"
"401":
description: 401 response
content:
application/json:
schema:
$ref: "#/components/schemas/GetOauth1401ResponseBody"
"200":
description: 200 response
content:
application/json:
schema:
$ref: "#/components/schemas/GetAuthHawk200ResponseBody"
/patch:
patch:
responses: {}
responses:
{}
requestBody:
content:
text/plain:
schema:
type: string
/post:
post:
responses: {}
responses:
{}
requestBody:
content:
text/plain:
Expand All @@ -420,7 +432,8 @@ paths:
type: string
/put:
put:
responses: {}
responses:
{}
requestBody:
content:
text/plain:
Expand Down Expand Up @@ -461,7 +474,8 @@ paths:
schema:
type: string
get:
responses: {}
responses:
{}
/time/{time}:
parameters:
- in: path
Expand Down Expand Up @@ -722,7 +736,8 @@ components:
- mixed
authenticated:
type: boolean
required: []
required:
[]
- type: array
items:
type: object
Expand Down Expand Up @@ -772,7 +787,8 @@ components:
type: string
folders:
type: array
items: {}
items:
{}
requests:
type: array
items:
Expand All @@ -790,7 +806,8 @@ components:
type: string
data:
type: array
items: {}
items:
{}
rawModeData:
type: string
tests:
Expand Down Expand Up @@ -895,7 +912,8 @@ components:
properties:
variables:
type: array
items: {}
items:
{}
info:
type: object
properties:
Expand Down Expand Up @@ -950,7 +968,8 @@ components:
type: string
header:
type: array
items: {}
items:
{}
body:
type: object
properties:
Expand All @@ -968,7 +987,8 @@ components:
- body
response:
type: array
items: {}
items:
{}
required:
- name
- request
Expand All @@ -985,7 +1005,8 @@ components:
type: string
folders:
type: array
items: {}
items:
{}
requests:
type: array
items:
Expand All @@ -1003,7 +1024,8 @@ components:
type: string
data:
type: array
items: {}
items:
{}
rawModeData:
type: string
tests:
Expand Down Expand Up @@ -1566,7 +1588,8 @@ GET /books
[200 response body] 'author_id' is now type number (/properties/books/items/properties/author_id)
[200 response body] 'status' now has enum value 'hold' (/properties/books/items/properties/status/enum)
[200 response body] schema (/properties/books/items/properties/price/maximum) with keyword 'maximum' and parameters {"comparison":"<=","limit":6} received invalid values 10, 15
 ⛔️ schema could not be automatically updated. Update the schema manually at openapi.yml:37:799
 ⛔️ schema could not be automatically updated. Update the schema manually at openapi.yml:42:924
...and 1 endpoint that did not receive traffic

Learning path patterns for unmatched requests...
Documenting new operations:
Expand All @@ -1585,13 +1608,18 @@ info:
version: 0.1.0
paths:
/books:
post:
"responses":
{}
get:
# a comment about something
responses:
"200":
description: 200 response
content:
application/json:
schema:
# use the refs here
$ref: "#/components/schemas/GetBooks200ResponseBody"
/authors:
get:
Expand Down Expand Up @@ -1641,6 +1669,7 @@ paths:
type: string
components:
schemas:
# this is a schema
GetBooks200ResponseBody:
type: object
properties:
Expand Down Expand Up @@ -1751,7 +1780,8 @@ GET /books
[200 response body] 'author_id' is now type number (/properties/books/items/properties/author_id)
[200 response body] 'status' now has enum value 'hold' (/properties/books/items/properties/status/enum)
[200 response body] schema (/properties/books/items/properties/price/maximum) with keyword 'maximum' and parameters {"comparison":"<=","limit":6} received invalid values 10, 15
 ⛔️ schema could not be automatically updated. Update the schema manually at openapi.yml:37:799
 ⛔️ schema could not be automatically updated. Update the schema manually at openapi.yml:42:924
...and 1 endpoint that did not receive traffic

5 unmatched requests
New endpoints are only added in interactive mode. Run 'optic capture openapi.yml --update interactive' to add new endpoints
Expand All @@ -1766,16 +1796,22 @@ info:
version: 0.1.0
paths:
/books:
post:
"responses":
{}
get:
# a comment about something
responses:
"200":
description: 200 response
content:
application/json:
schema:
# use the refs here
$ref: "#/components/schemas/GetBooks200ResponseBody"
components:
schemas:
# this is a schema
GetBooks200ResponseBody:
type: object
properties:
Expand Down Expand Up @@ -1848,39 +1884,40 @@ GET /books
[200 response body] 'updated_at' is not documented (/properties/books/items/properties)
[200 response body] 'author_id' does not match type number. Received 6nTxAFM5ck4Hob77hGQoL (/properties/books/items/properties/author_id)
 Diff  'author_id' did not match schema
25 | properties:
26 | id:
27 | type: string
28 |  author_id: [Actual] "6nTxAFM5ck4Hob77hGQoL"
29 | type: number
30 | status:
31 | type: string
30 | properties:
31 | id:
32 | type: string
33 |  author_id: [Actual] "6nTxAFM5ck4Hob77hGQoL"
34 | type: number
35 | status:
36 | type: string
$workspace$/openapi.yml

[200 response body] 'status' missing enum value 'hold' (/properties/books/items/properties/status/enum)
 Diff  'status' does not have enum value hold
29 | type: number
30 | status:
31 | type: string
32 |  enum: missing enum value 'hold'
33 | - ready
34 | - not_ready
35 | price:
34 | type: number
35 | status:
36 | type: string
37 |  enum: missing enum value 'hold'
38 | - ready
39 | - not_ready
40 | price:
$workspace$/openapi.yml

[200 response body] schema (/properties/books/items/properties/price/maximum) with keyword 'maximum' and parameters {"comparison":"<=","limit":6} received invalid values 10, 15
 Diff  interaction did not match schema
34 | - not_ready
35 | price:
36 | type: number
37 |  maximum: 6 [Actual] 10, 15
38 | minimum: 2
39 | required:
40 | - id
39 | - not_ready
40 | price:
41 | type: number
42 |  maximum: 6 [Actual] 10, 15
43 | minimum: 2
44 | required:
45 | - id
$workspace$/openapi.yml

...and 1 endpoint that did not receive traffic

100.0% coverage of your documented operations. 5 requests did not match a documented path (6 total requests).
66.7% coverage of your documented operations. 5 requests did not match a documented path (6 total requests).
9 diffs detected in documented operations

New endpoints are only added in interactive mode. Run 'optic capture openapi.yml --update interactive' to add new endpoints
Expand All @@ -1897,8 +1934,9 @@ GET /books
[200 response body] 'author_id' does not match type number. Received 6nTxAFM5ck4Hob77hGQoL (/properties/books/items/properties/author_id)
[200 response body] 'status' missing enum value 'hold' (/properties/books/items/properties/status/enum)
[200 response body] schema (/properties/books/items/properties/price/maximum) with keyword 'maximum' and parameters {"comparison":"<=","limit":6} received invalid values 10, 15
...and 1 endpoint that did not receive traffic

100.0% coverage of your documented operations. 5 requests did not match a documented path (6 total requests).
66.7% coverage of your documented operations. 5 requests did not match a documented path (6 total requests).
6 diffs detected in documented operations

New endpoints are only added in interactive mode. Run 'optic capture openapi.yml --update interactive' to add new endpoints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ info:
version: 0.1.0
paths:
/books:
post:
"responses": {}
get:
# a comment about something
responses:
"200":
description: 200 response
content:
application/json:
schema:
# use the refs here
$ref: "#/components/schemas/GetBooks200ResponseBody"
components:
schemas:
# this is a schema
GetBooks200ResponseBody:
type: object
properties:
Expand Down
Loading