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

openapi3: reference originating locations in YAML specs - step 1 #1007

Merged
merged 46 commits into from
Oct 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
20a9abd
add origin - step 1
reuvenharrison Aug 19, 2024
f90371a
delete origin from content
reuvenharrison Aug 20, 2024
7d41bd0
point to Origin
reuvenharrison Aug 21, 2024
77f909b
make include origin configurable
reuvenharrison Aug 22, 2024
15e7cab
generic unmarshalStringMap
reuvenharrison Aug 23, 2024
450e4d0
add origin to more components
reuvenharrison Aug 25, 2024
6b52b19
revert comments
reuvenharrison Aug 25, 2024
775ab17
use const originKey
reuvenharrison Aug 25, 2024
d241445
comment to Scopes
reuvenharrison Aug 26, 2024
206c1be
test more specs
reuvenharrison Aug 26, 2024
032ff76
Fix Discriminator
reuvenharrison Sep 17, 2024
4304772
update docs
reuvenharrison Sep 17, 2024
67ee9fa
test on a decent set of dedicated specs
reuvenharrison Sep 17, 2024
8095459
remove trainling spaces
reuvenharrison Sep 17, 2024
d24b68a
add comments
reuvenharrison Sep 17, 2024
c5cf284
remove trailing whitespace
reuvenharrison Sep 17, 2024
98ace80
update docs
reuvenharrison Sep 17, 2024
c981f30
dedicated tests
reuvenharrison Sep 17, 2024
6daf324
update docs
reuvenharrison Sep 17, 2024
17db6ab
remove whitespace
reuvenharrison Sep 17, 2024
015b63e
rm empty line
reuvenharrison Sep 17, 2024
34f95b7
rm last newline
reuvenharrison Sep 17, 2024
020e44b
add tests
reuvenharrison Sep 19, 2024
07a3b25
rm unused test files
reuvenharrison Sep 20, 2024
cba19cf
update deps
reuvenharrison Sep 20, 2024
2d5e393
fix paths test
reuvenharrison Sep 20, 2024
b9f7dd6
test components/security
reuvenharrison Sep 20, 2024
aa8c5b1
fix LF
reuvenharrison Sep 20, 2024
8a00ba0
include origin in unmarshal maps
reuvenharrison Sep 21, 2024
3aca4e0
move component unmarshallers to respective files
reuvenharrison Oct 14, 2024
7ea36a0
fix test (json-schema 301)
reuvenharrison Oct 14, 2024
929edf0
Add github.com/pb33f/libopenapi (#1004)
Jille Aug 22, 2024
d2c2b3c
Introduce an option to override the regex implementation (#1006)
alexbakker Aug 26, 2024
0125b1b
make form required field order deterministic (#1008)
jlsherrill Aug 30, 2024
45f4435
openapi2: fix un/marshalling discriminator field (#1011)
reversearrow Oct 1, 2024
cfdf905
README: add Fuego to dependents (#1017)
EwenQuim Oct 8, 2024
dd25946
openapi3: skip a test in CI to avoid 403s from some remote server (#1…
fenollp Oct 14, 2024
8113413
revert fix test (json-schema 301)
reuvenharrison Oct 16, 2024
4f2e185
openapi3: introduce StringMap type to enable unmarshalling of maps wi…
reuvenharrison Oct 16, 2024
e3b2867
add origin to more components
reuvenharrison Aug 25, 2024
3cba697
Fix Discriminator
reuvenharrison Sep 17, 2024
74dcf9e
update docs
reuvenharrison Sep 17, 2024
712c943
update doccs
reuvenharrison Oct 16, 2024
9aadd59
merge with stringmap
reuvenharrison Oct 16, 2024
184fa8c
remove unused Scopes
reuvenharrison Oct 16, 2024
5df8e49
Merge branch 'master' into master
reuvenharrison Oct 16, 2024
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
Prev Previous commit
Next Next commit
test on a decent set of dedicated specs
reuvenharrison committed Sep 17, 2024
commit 67ee9fa7a743ca4a50b1aafac09ee4c56d33b3b1
14 changes: 1 addition & 13 deletions openapi3/openapi3_test.go
Original file line number Diff line number Diff line change
@@ -485,21 +485,9 @@ func TestOrigin(t *testing.T) {
loader.IncludeOrigin = true
loader.Context = context.Background()

const dir = "testdata"
const dir = "testdata/origin"
items, _ := os.ReadDir(dir)
for _, item := range items {
if item.IsDir() {
continue
}
if strings.HasSuffix(item.Name(), ".json") {
continue
}
if item.Name() == "issue235.spec0-typo.yml" ||
item.Name() == "callbacks.yml.internalized.yml" ||
item.Name() == "spec.yaml.internalized.yml" ||
item.Name() == "testref.openapi.yml.internalized.yml" {
continue
}
t.Run(item.Name(), func(t *testing.T) {
doc, err := loader.LoadFromFile(fmt.Sprintf("%s/%s", dir, item.Name()))
require.NoError(t, err)
58 changes: 58 additions & 0 deletions openapi3/testdata/origin/add_new_media_type_base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
openapi: 3.0.1
info:
title: Tufin
version: "2.0"
servers:
- url: https://localhost:9080
paths:
/api/v1.0/groups:
post:
operationId: createOneGroup
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/GroupView'
description: Creates one project.
required: true
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/GroupView'
description: OK
"409":
content:
application/json:
schema:
$ref: '#/components/schemas/GroupView'
description: Conflict
summary: Create One Project
components:
parameters:
groupId:
in: path
name: groupId
required: true
schema:
type: string
schemas:
GroupView:
type: object
properties:
data:
type: object
properties:
created:
type: string
format: date-time
readOnly: true
pattern: "^[a-z]+$"
id:
type: string
readOnly: true
name:
type: string
required:
- name
68 changes: 68 additions & 0 deletions openapi3/testdata/origin/add_new_media_type_revision.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
openapi: 3.0.1
info:
title: Tufin
version: "2.0"
servers:
- url: https://localhost:9080
paths:
/api/v1.0/groups:
post:
operationId: createOneGroup
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/GroupView'
description: Creates one project.
required: true
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/GroupView'
application/xml: # Another media type
schema:
type: object
properties:
id:
type: integer
name:
type: string
fullTime:
type: boolean
description: OK
"409":
content:
application/json:
schema:
$ref: '#/components/schemas/GroupView'
description: Conflict
summary: Create One Project
components:
parameters:
groupId:
in: path
name: groupId
required: true
schema:
type: string
schemas:
GroupView:
type: object
properties:
data:
type: object
properties:
created:
type: string
format: date-time
readOnly: true
pattern: "^[a-z]+$"
id:
type: string
readOnly: true
name:
type: string
required:
- name
33 changes: 33 additions & 0 deletions openapi3/testdata/origin/api_security_added_base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
openapi: 3.0.0
info:
title: Security Requirement Example
version: 1.0.0
paths:
/subscribe:
post:
requestBody:
content:
application/json:
schema:
type: object
properties:
inProgressUrl:
type: string
failedUrl:
type: string
successUrl:
type: string
responses:
"200":
description: OK
components:
securitySchemes:
petstore_auth:
type: oauth2
flows:
implicit:
authorizationUrl: http://example.org/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets

37 changes: 37 additions & 0 deletions openapi3/testdata/origin/api_security_added_revision.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
openapi: 3.0.0
info:
title: Security Requirement Example
version: 1.0.0
paths:
/subscribe:
post:
requestBody:
content:
application/json:
schema:
type: object
properties:
inProgressUrl:
type: string
failedUrl:
type: string
successUrl:
type: string
responses:
"200":
description: OK
security:
- petstore_auth:
- write:pets
- read:pets
components:
securitySchemes:
petstore_auth:
type: oauth2
flows:
implicit:
authorizationUrl: http://example.org/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets

33 changes: 33 additions & 0 deletions openapi3/testdata/origin/api_security_global_added_base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
openapi: 3.0.0
info:
title: Security Requirement Example
version: 1.0.0
paths:
/subscribe:
post:
requestBody:
content:
application/json:
schema:
type: object
properties:
inProgressUrl:
type: string
failedUrl:
type: string
successUrl:
type: string
responses:
"200":
description: OK
components:
securitySchemes:
petstore_auth:
type: oauth2
flows:
implicit:
authorizationUrl: http://example.org/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets

37 changes: 37 additions & 0 deletions openapi3/testdata/origin/api_security_global_added_revision.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
openapi: 3.0.0
info:
title: Security Requirement Example
version: 1.0.0
security:
- petstore_auth:
- write:pets
- read:pets
paths:
/subscribe:
post:
requestBody:
content:
application/json:
schema:
type: object
properties:
inProgressUrl:
type: string
failedUrl:
type: string
successUrl:
type: string
responses:
"200":
description: OK
components:
securitySchemes:
petstore_auth:
type: oauth2
flows:
implicit:
authorizationUrl: http://example.org/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets

46 changes: 46 additions & 0 deletions openapi3/testdata/origin/api_security_updated_base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
openapi: 3.0.0
info:
title: Security Requirement Example
version: 1.0.0
paths:
/subscribe:
post:
requestBody:
content:
application/json:
schema:
type: object
properties:
inProgressUrl:
type: string
failedUrl:
type: string
successUrl:
type: string
responses:
"200":
description: OK
security:
- petstore_auth:
- write:pets
- read:pets
components:
securitySchemes:
petstore_auth:
type: oauth2
flows:
implicit:
authorizationUrl: http://example.org/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets
catstore_auth:
type: oauth2
flows:
implicit:
authorizationUrl: http://example.org/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets


43 changes: 43 additions & 0 deletions openapi3/testdata/origin/api_security_updated_revision.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
openapi: 3.0.0
info:
title: Security Requirement Example
version: 1.0.0
paths:
/subscribe:
post:
requestBody:
content:
application/json:
schema:
type: object
properties:
inProgressUrl:
type: string
failedUrl:
type: string
successUrl:
type: string
responses:
"200":
description: OK
security:
- petstore_auth:
- write:pets
components:
securitySchemes:
petstore_auth:
type: oauth2
flows:
implicit:
authorizationUrl: http://example.org/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets
catstore_auth:
type: oauth2
flows:
implicit:
authorizationUrl: http://example.org/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets
Loading