Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

#2 Fixing openapi3.Components Bug #3

Merged
merged 2 commits into from
Jul 1, 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
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ module goyave.dev/openapi3
go 1.16

require (
github.com/getkin/kin-openapi v0.95.0
github.com/getkin/kin-openapi v0.113.0
github.com/go-openapi/swag v0.21.1 // indirect
github.com/imdario/mergo v0.3.13
github.com/mailru/easyjson v0.7.7 // indirect
github.com/stretchr/testify v1.8.1
golang.org/x/text v0.4.0
goyave.dev/goyave/v4 v4.0.0
Expand Down
18 changes: 14 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denisenkom/go-mssqldb v0.11.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/getkin/kin-openapi v0.95.0 h1:L6SaixpXTbeEkvq/ivX02g0MRQ2mQMOr0gw2gwZeNnM=
github.com/getkin/kin-openapi v0.95.0/go.mod h1:LWZfzOd7PRy8GJ1dJ6mCU6tNdSfOwRac1BUPam4aw6Q=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/getkin/kin-openapi v0.113.0 h1:t9aNS/q5Agr7a55Jp1AuZ3sR2WzHESv3Dd2ys4UphsM=
github.com/getkin/kin-openapi v0.113.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
Expand All @@ -25,6 +23,8 @@ github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/e
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
Expand All @@ -36,6 +36,8 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/invopop/yaml v0.1.0 h1:YW3WGUoJEXYfzWBjn00zIlrw7brGVD0fUKRYDPAPhrc=
github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
Expand Down Expand Up @@ -109,8 +111,12 @@ github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/perimeterx/marshmallow v1.1.4 h1:pZLDH9RjlLGGorbXhcaQLhfuV0pFMNfPO55FuFkxqLw=
github.com/perimeterx/marshmallow v1.1.4/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -138,6 +144,10 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
Expand Down
2 changes: 1 addition & 1 deletion openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (g *Generator) Generate(router *goyave.Router) *openapi3.T {
},
Paths: make(openapi3.Paths),
Servers: makeServers(),
Components: openapi3.Components{
Components: &openapi3.Components{
Schemas: make(openapi3.Schemas),
RequestBodies: make(openapi3.RequestBodies),
Responses: make(openapi3.Responses),
Expand Down
14 changes: 7 additions & 7 deletions route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (c testController) handler(resp *goyave.Response, req *goyave.Request) {
}

func (suite *RouteTestSuite) TestGetParamSchema() {
spec := &openapi3.T{Components: openapi3.Components{Schemas: openapi3.Schemas{}}}
spec := &openapi3.T{Components: &openapi3.Components{Schemas: openapi3.Schemas{}}}
refs := NewRefs()
router := goyave.NewRouter()
route := router.Get("/test/{param}/{id:[0-9]+}/{notint:[a-z0-9]+}", HandlerTest)
Expand Down Expand Up @@ -243,7 +243,7 @@ func (suite *RouteTestSuite) TestGetParamSchema() {
}

func (suite *RouteTestSuite) TestGetParamSchemaCacheAndNaming() {
spec := &openapi3.T{Components: openapi3.Components{Schemas: openapi3.Schemas{}}}
spec := &openapi3.T{Components: &openapi3.Components{Schemas: openapi3.Schemas{}}}
refs := NewRefs()
router := goyave.NewRouter()
route := router.Get("/{param1:[a-z0-9]+}/{param2:[a-z0-9]+}", HandlerTest)
Expand All @@ -265,7 +265,7 @@ func (suite *RouteTestSuite) TestGetParamSchemaCacheAndNaming() {

func (suite *RouteTestSuite) TestConvertPathParameter() {
spec := &openapi3.T{
Components: openapi3.Components{
Components: &openapi3.Components{
Schemas: openapi3.Schemas{},
Parameters: openapi3.ParametersMap{},
},
Expand Down Expand Up @@ -322,7 +322,7 @@ func (suite *RouteTestSuite) TestConvertPathParameter() {

func (suite *RouteTestSuite) TestConvertValidationRules() {
spec := &openapi3.T{
Components: openapi3.Components{
Components: &openapi3.Components{
Schemas: openapi3.Schemas{},
Parameters: openapi3.ParametersMap{},
},
Expand Down Expand Up @@ -362,7 +362,7 @@ func (suite *RouteTestSuite) TestConvertValidationRules() {

func (suite *RouteTestSuite) TestConvertValidationRulesWithBody() {
spec := &openapi3.T{
Components: openapi3.Components{
Components: &openapi3.Components{
Schemas: openapi3.Schemas{},
Parameters: openapi3.ParametersMap{},
RequestBodies: openapi3.RequestBodies{},
Expand Down Expand Up @@ -411,7 +411,7 @@ func findQueryParamRef(query []*openapi3.ParameterRef, ref string) *openapi3.Par

func (suite *RouteTestSuite) TestConvertOperation() {
spec := &openapi3.T{
Components: openapi3.Components{
Components: &openapi3.Components{
Schemas: openapi3.Schemas{},
Parameters: openapi3.ParametersMap{},
RequestBodies: openapi3.RequestBodies{},
Expand Down Expand Up @@ -447,7 +447,7 @@ func (suite *RouteTestSuite) TestConvertOperation() {

func (suite *RouteTestSuite) TestConvert() {
spec := &openapi3.T{
Components: openapi3.Components{
Components: &openapi3.Components{
Schemas: openapi3.Schemas{},
Parameters: openapi3.ParametersMap{},
RequestBodies: openapi3.RequestBodies{},
Expand Down
4 changes: 2 additions & 2 deletions ui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const (
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
spec: {"components":{},"info":{"title":"Test","version":"0.0.0"},"openapi":"3.0.0","paths":{}},
spec: {"info":{"title":"Test","version":"0.0.0"},"openapi":"3.0.0","paths":{}},
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
Expand Down Expand Up @@ -83,7 +83,7 @@ func (suite *UITestSuite) TestNewOptions() {
}
opts := NewUIOptions(spec)
suite.NotNil(opts)
suite.Equal(`{"components":{},"info":{"title":"Test","version":"0.0.0"},"openapi":"3.0.0","paths":{}}`, opts.Spec)
suite.Equal(`{"info":{"title":"Test","version":"0.0.0"},"openapi":"3.0.0","paths":{}}`, opts.Spec)
suite.NotEmpty(opts.Favicon16)
suite.NotEmpty(opts.Favicon32)
suite.NotEmpty(opts.BundleURL)
Expand Down