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

Commit 1f7febe

Browse files
feat: update faker
1 parent 771816d commit 1f7febe

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/cristalhq/acmd v0.7.0
77
github.com/goccy/go-yaml v1.9.5
88
github.com/lamoda/gonkey v1.18.2
9-
github.com/neotoolkit/faker v0.1.2
9+
github.com/neotoolkit/faker v0.9.1
1010
github.com/neotoolkit/openapi v0.10.0
1111
github.com/stretchr/testify v1.8.0
1212
go.uber.org/zap v1.21.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HK
8888
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
8989
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
9090
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
91-
github.com/neotoolkit/faker v0.1.2 h1:4/Xbk8DssKBZFUA/wIpWeGvWM9KMlQoitLFck3KROdg=
92-
github.com/neotoolkit/faker v0.1.2/go.mod h1:ChsI+y4MR3t1Ybbt0ktUXqDVJTq9w9oXuL59jJ5ufF4=
91+
github.com/neotoolkit/faker v0.9.1 h1:Z5bvSQoqm9usI2Q6X5/7aeUhhI81geTcy2VP5Qdaay8=
92+
github.com/neotoolkit/faker v0.9.1/go.mod h1:xo8gPYed0+xG7RQHV3wwKMyE4i0wkMMjNoyxjihgWno=
9393
github.com/neotoolkit/openapi v0.10.0 h1:kg7hrBQc3CxkwVkrWp0MXzqxWMcCQGuQZDWKBJLeZY4=
9494
github.com/neotoolkit/openapi v0.10.0/go.mod h1:/Yh4psCpGJAbsMCmp2W8dkL+JQjBYChxtAeeCDNoCsc=
9595
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=

internal/api/build.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func ParseObjectExample(data any) (map[string]any, error) {
7777
type Builder struct {
7878
OpenAPI openapi.OpenAPI
7979
Operations []Operation
80-
Faker faker.Faker
8180
}
8281

8382
// Build -.
@@ -232,8 +231,9 @@ func (b *Builder) convertSchema(s openapi.Schema) (Schema, error) {
232231
s = schema
233232
}
234233

235-
if s.Faker != "" {
236-
return FakerSchema{Example: b.Faker.ByName(s.Faker)}, nil
234+
f, err := faker.Faker(s.Faker)
235+
if s.Faker != "" && err == nil {
236+
return FakerSchema{Example: f}, nil
237237
}
238238

239239
switch s.Type {

internal/parse/parse.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"path/filepath"
66

77
"github.com/goccy/go-yaml"
8-
"github.com/neotoolkit/faker"
98
"github.com/neotoolkit/openapi"
109

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

64-
f := faker.NewFaker()
65-
6663
b := &api.Builder{
6764
OpenAPI: oapi,
68-
Faker: f,
6965
}
7066

7167
return b.Build()

0 commit comments

Comments
 (0)