FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
oasdiff/diff/item_schema_test.go at main · oasdiff/oasdiff · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
oasdiff
/
oasdiff
Public
Notifications
You must be signed in to change notification settings
Fork
103
Star
1.3k
Code
Issues
51
Pull requests
3
Discussions
Actions
Projects
Security and quality
2
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
oasdiff
/
diff
/
item_schema_test.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (36 loc) · 1.85 KB
Breadcrumbs
oasdiff
/
diff
/
item_schema_test.go
Copy path
File metadata and controls
46 lines (36 loc) · 1.85 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package
diff_test
import
(
"testing"
"github.com/getkin/kin-openapi/openapi3"
"github.com/oasdiff/oasdiff/diff"
"github.com/oasdiff/oasdiff/load"
"github.com/stretchr/testify/require"
)
// itemSchema (OpenAPI 3.2) describes one item of a streamed body. It is diffed
// with the same schema-diff engine as schema, so it inherits property, type,
// constraint and enum comparison rather than reimplementing any of it.
func
TestDiff_ItemSchema
(
t
*
testing.
T
) {
loader
:=
openapi3
.
NewLoader
()
s1
,
err
:=
load
.
NewSpecInfo
(
loader
,
load
.
NewSource
(
"../data/item-schema/base.yaml"
))
require
.
NoError
(
t
,
err
)
s2
,
err
:=
load
.
NewSpecInfo
(
loader
,
load
.
NewSource
(
"../data/item-schema/revision.yaml"
))
require
.
NoError
(
t
,
err
)
d
,
_
,
err
:=
diff
.
GetWithOperationsSourcesMap
(
diff
.
NewConfig
(),
s1
,
s2
)
require
.
NoError
(
t
,
err
)
requestItem
:=
d
.
PathsDiff
.
Modified
[
"/ingest"
].
OperationsDiff
.
Modified
[
"POST"
].
RequestBodyDiff
.
ContentDiff
.
MediaTypeModified
[
"application/jsonl"
].
ItemSchemaDiff
require
.
NotNil
(
t
,
requestItem
)
require
.
Contains
(
t
,
requestItem
.
RequiredDiff
.
Added
,
"weight"
)
responseItem
:=
d
.
PathsDiff
.
Modified
[
"/events"
].
OperationsDiff
.
Modified
[
"GET"
].
ResponsesDiff
.
Modified
[
"200"
].
ContentDiff
.
MediaTypeModified
[
"text/event-stream"
].
ItemSchemaDiff
require
.
NotNil
(
t
,
responseItem
)
require
.
NotEmpty
(
t
,
responseItem
.
PropertiesDiff
.
Modified
)
// An itemSchema present on base only is deleted, not modified.
dropped
:=
d
.
PathsDiff
.
Modified
[
"/drop"
].
OperationsDiff
.
Modified
[
"POST"
].
ResponsesDiff
.
Modified
[
"200"
].
ContentDiff
.
MediaTypeModified
[
"application/jsonl"
].
ItemSchemaDiff
require
.
True
(
t
,
dropped
.
SchemaDeleted
)
// An itemSchema present on revision only is added, not modified.
added
:=
d
.
PathsDiff
.
Modified
[
"/drop"
].
OperationsDiff
.
Modified
[
"POST"
].
RequestBodyDiff
.
ContentDiff
.
MediaTypeModified
[
"application/jsonl"
].
ItemSchemaDiff
require
.
True
(
t
,
added
.
SchemaAdded
)
}
Back
|
FazBrowse Home
|
New Git URL