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

PMM-7 pull upstream changes #4

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f85abf4
Fix #165
Apr 19, 2023
7ee5140
Merge pull request #166 from Aven30/fix-spec-parser-ignoring-response…
casualjim Apr 22, 2023
b123375
Fix `x-order` not working with number value #162
ChandanChainani Mar 6, 2023
832384d
Merge pull request #163 from ChandanChainani/fix/162/x-order_not_work…
casualjim Apr 22, 2023
32e224f
fixed json unmarshal for BoolOrSchema
fredbi Nov 30, 2023
d8ccc36
ci: re-enacted linting
fredbi Nov 30, 2023
0da2f93
chore: updated linting config, relinted
fredbi Nov 30, 2023
2341568
ci: removed deprecated appveyor CI
fredbi Nov 30, 2023
cc27dbe
Merge pull request #170 from fredbi/chore/update-linting
casualjim Dec 1, 2023
ba7eeb1
Merge pull request #169 from fredbi/ci/reenact-linting
casualjim Dec 1, 2023
8b1afa6
Merge pull request #171 from fredbi/vuln/fix-161
casualjim Dec 1, 2023
95bb41d
Merge pull request #168 from fredbi/fix-148
casualjim Dec 1, 2023
d6c58be
updated go version
fredbi Dec 4, 2023
5762ed3
Removed dependency on bindata
fredbi Dec 4, 2023
b250982
Revert fix #146 (#172)
fredbi Dec 4, 2023
56b7b69
Merge pull request #173 from fredbi/chore/update-go-version
youyuanwu Dec 5, 2023
0bd5b7c
Merge pull request #174 from fredbi/chore/adopt-embedfs
youyuanwu Dec 5, 2023
7d71eda
doc: fixed typo in badge link
fredbi Dec 5, 2023
4df02b2
fixed yet another typo with badges
fredbi Dec 5, 2023
94a1c0d
updated dependencies
fredbi Dec 17, 2023
8789dc3
removed pre-go1.19 code
fredbi Dec 17, 2023
ee158df
chore(deps): updated go-openapi deps
fredbi Dec 22, 2023
b445199
fix(ci): muted warnings in CI runs due to cache conflicts
fredbi Dec 25, 2023
ed00e71
fix(expand): parameters & responses should properly follow remote doc…
fredbi Jan 9, 2024
63dcade
doc(faq): transfered questions to README
fredbi Jan 9, 2024
4c02b81
ci(dependencies): automate dependencies updates
fredbi Feb 1, 2024
7e0aabf
Bump the go-openapi-dependencies group with 1 update
dependabot[bot] Feb 1, 2024
5c52f3d
Bump the development-dependencies group with 3 updates
dependabot[bot] Feb 1, 2024
817cb94
chore(ci): prevents duplicate workflow runs
fredbi Feb 1, 2024
c21b34f
Bump the development-dependencies group with 1 update
dependabot[bot] Feb 2, 2024
a68da9e
ci: remove paths-ignore
fredbi Feb 3, 2024
397f81b
Bump the development-dependencies group with 1 update
dependabot[bot] Feb 16, 2024
c786eed
fix(ci): remove dependency-type from dependabot groups
fredbi Mar 4, 2024
fc76ee8
chore(lint): relinted
fredbi Mar 4, 2024
8937a3d
updated dependencies
fredbi Mar 4, 2024
af9bab8
chore(go): go-openapi requires go.1.20 across the board
fredbi Mar 9, 2024
7246d41
Bump the development-dependencies group with 1 update
dependabot[bot] Mar 22, 2024
2a63555
Bump golangci/golangci-lint-action in the development-dependencies group
dependabot[bot] Apr 26, 2024
7b021a9
Bump golangci/golangci-lint-action in the development-dependencies group
dependabot[bot] May 10, 2024
96bee35
Bump codecov/codecov-action in the development-dependencies group
dependabot[bot] Nov 15, 2024
302430d
Bump github.com/stretchr/testify from 1.9.0 to 1.10.0
dependabot[bot] Nov 29, 2024
de35272
Merge pull request #204 from go-openapi/dependabot/go_modules/github.…
youyuanwu Feb 5, 2025
0201d0c
Relint
fredbi Mar 11, 2025
9deaa98
re-enacted dependabot auto-merge
fredbi Mar 12, 2025
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
fixed json unmarshal for BoolOrSchema
According to the json draft 4 (or later) spec, empty schema is
equivalent to true.

* checked with the OP's test case (spec expansion)
* added unit test
* fixes go-openapi#148

Signed-off-by: Frederic BIDON <[email protected]>
fredbi committed Nov 30, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 32e224fa44f2606581f73b07fc83caeba482f5f1
31 changes: 31 additions & 0 deletions expander_test.go
Original file line number Diff line number Diff line change
@@ -42,6 +42,37 @@ var (
specs = filepath.Join("fixtures", "specs")
)

func TestExpand_Issue148(t *testing.T) {
fp := filepath.Join("fixtures", "bugs", "schema-148.json")
b, err := jsonDoc(fp)
require.NoError(t, err)

assertAdditionalProps := func(sp Swagger) func(*testing.T) {
return func(t *testing.T) {
require.Len(t, sp.Definitions, 2)

require.Contains(t, sp.Definitions, "empty")
empty := sp.Definitions["empty"]
require.NotNil(t, empty.AdditionalProperties)
require.NotNil(t, empty.AdditionalProperties.Schema)
require.True(t, empty.AdditionalProperties.Allows)

require.Contains(t, sp.Definitions, "false")
additionalIsFalse := sp.Definitions["false"]
require.NotNil(t, additionalIsFalse.AdditionalProperties)
require.Nil(t, additionalIsFalse.AdditionalProperties.Schema)
require.False(t, additionalIsFalse.AdditionalProperties.Allows)
}
}

var sp Swagger
require.NoError(t, json.Unmarshal(b, &sp))
t.Run("check additional properties", assertAdditionalProps(sp))

require.NoError(t, ExpandSpec(&sp, nil))
t.Run("check additional properties after expansion", assertAdditionalProps(sp))
}

func TestExpand_KnownRef(t *testing.T) {
// json schema draft 4 meta schema is embedded by default: it resolves without setup
schema := RefProperty("http://json-schema.org/draft-04/schema#")
10 changes: 10 additions & 0 deletions fixtures/bugs/schema-148.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"definitions": {
"empty": {
"additionalProperties": {}
},
"false": {
"additionalProperties": false
}
}
}
4 changes: 2 additions & 2 deletions swagger.go
Original file line number Diff line number Diff line change
@@ -253,15 +253,15 @@ func (s SchemaOrBool) MarshalJSON() ([]byte, error) {
// UnmarshalJSON converts this bool or schema object from a JSON structure
func (s *SchemaOrBool) UnmarshalJSON(data []byte) error {
var nw SchemaOrBool
if len(data) >= 4 {
if len(data) > 0 {
if data[0] == '{' {
var sch Schema
if err := json.Unmarshal(data, &sch); err != nil {
return err
}
nw.Schema = &sch
}
nw.Allows = !(data[0] == 'f' && data[1] == 'a' && data[2] == 'l' && data[3] == 's' && data[4] == 'e')
nw.Allows = !bytes.Equal(data, []byte("false"))
}
*s = nw
return nil