Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #356 from neotoolkit/feat/faker
Browse files Browse the repository at this point in the history
feat: update faker
  • Loading branch information
sashamelentyev authored Jul 11, 2022
2 parents 771816d + 1f7febe commit 89222de
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/cristalhq/acmd v0.7.0
github.com/goccy/go-yaml v1.9.5
github.com/lamoda/gonkey v1.18.2
github.com/neotoolkit/faker v0.1.2
github.com/neotoolkit/faker v0.9.1
github.com/neotoolkit/openapi v0.10.0
github.com/stretchr/testify v1.8.0
go.uber.org/zap v1.21.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HK
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/neotoolkit/faker v0.1.2 h1:4/Xbk8DssKBZFUA/wIpWeGvWM9KMlQoitLFck3KROdg=
github.com/neotoolkit/faker v0.1.2/go.mod h1:ChsI+y4MR3t1Ybbt0ktUXqDVJTq9w9oXuL59jJ5ufF4=
github.com/neotoolkit/faker v0.9.1 h1:Z5bvSQoqm9usI2Q6X5/7aeUhhI81geTcy2VP5Qdaay8=
github.com/neotoolkit/faker v0.9.1/go.mod h1:xo8gPYed0+xG7RQHV3wwKMyE4i0wkMMjNoyxjihgWno=
github.com/neotoolkit/openapi v0.10.0 h1:kg7hrBQc3CxkwVkrWp0MXzqxWMcCQGuQZDWKBJLeZY4=
github.com/neotoolkit/openapi v0.10.0/go.mod h1:/Yh4psCpGJAbsMCmp2W8dkL+JQjBYChxtAeeCDNoCsc=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down
6 changes: 3 additions & 3 deletions internal/api/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func ParseObjectExample(data any) (map[string]any, error) {
type Builder struct {
OpenAPI openapi.OpenAPI
Operations []Operation
Faker faker.Faker
}

// Build -.
Expand Down Expand Up @@ -232,8 +231,9 @@ func (b *Builder) convertSchema(s openapi.Schema) (Schema, error) {
s = schema
}

if s.Faker != "" {
return FakerSchema{Example: b.Faker.ByName(s.Faker)}, nil
f, err := faker.Faker(s.Faker)
if s.Faker != "" && err == nil {
return FakerSchema{Example: f}, nil
}

switch s.Type {
Expand Down
4 changes: 0 additions & 4 deletions internal/parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"path/filepath"

"github.com/goccy/go-yaml"
"github.com/neotoolkit/faker"
"github.com/neotoolkit/openapi"

"github.com/neotoolkit/dummy/internal/api"
Expand Down Expand Up @@ -61,11 +60,8 @@ func Parse(path string) (api.API, error) {
return api.API{}, err
}

f := faker.NewFaker()

b := &api.Builder{
OpenAPI: oapi,
Faker: f,
}

return b.Build()
Expand Down

0 comments on commit 89222de

Please sign in to comment.