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

fix: ozzo validation #134

Merged
merged 8 commits into from
Feb 16, 2024
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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ go 1.19
require (
github.com/getkin/kin-openapi v0.89.0
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.5.0
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.32.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.18.1
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
)
Expand All @@ -29,7 +31,6 @@ require (
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
Expand All @@ -40,7 +41,6 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
5 changes: 3 additions & 2 deletions pkg/generators/models/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import (
"path/filepath"
"strings"

tpl "github.com/contiamo/openapi-generator-go/v2/pkg/generators/templates"
"github.com/getkin/kin-openapi/openapi3"
"github.com/pkg/errors"
"github.com/rs/zerolog"

tpl "github.com/contiamo/openapi-generator-go/v2/pkg/generators/templates"
)

// DefaultPackageName used in the models source code
Expand Down Expand Up @@ -284,7 +285,7 @@ func (g generator) writeModelToFile(ctx context.Context, model *Model, dst strin
log.Debug().Msg("Formatting the rendered code...")
content, err := format.Source(buf.Bytes())
if err != nil {
return errors.Wrap(err, "cannot format model code")
return errors.Wrap(err, "cannot format model code: "+buf.String())
}
log.Debug().Msg("Code has been formatted.")

Expand Down
6 changes: 0 additions & 6 deletions pkg/generators/models/go_type_from_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ func goTypeFromSpec(schemaRef *openapi3.SchemaRef) string {
propertyType = "interface{}"
}

if schema.Nullable &&
!strings.HasPrefix(propertyType, "[]") &&
!strings.HasPrefix(propertyType, "map[") {

propertyType = "*" + propertyType
}
return propertyType
}

Expand Down
Loading
Loading