Skip to content

Commit 3813ec9

Browse files
authored
refactor: merge serviceuser in service module (#157)
1 parent 907258e commit 3813ec9

File tree

6 files changed

+344
-695
lines changed

6 files changed

+344
-695
lines changed

client_generated.go

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ Service:
292292
- ServiceTaskCreate
293293
- ServiceTaskGet
294294
- ServiceUpdate
295-
ServiceUser:
296295
- ServiceUserCreate
297296
- ServiceUserCredentialsModify
298297
- ServiceUserCredentialsReset

generator/models.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,28 @@ type Doc struct {
2626
} `json:"components"`
2727
}
2828

29+
const componentIndex = 3
30+
2931
func (d *Doc) getSchema(path string) (*Schema, error) {
30-
name := strings.Split(path, "/")[3]
32+
chunks := strings.Split(path, "/")
33+
if len(chunks) < componentIndex+1 {
34+
return nil, fmt.Errorf("invalid schema path %q", path)
35+
}
3136

37+
name := chunks[componentIndex]
3238
schema := d.Components.Schemas[name]
39+
for i := componentIndex + 1; i < len(chunks); i++ {
40+
switch k := chunks[i]; k {
41+
case "items":
42+
schema = schema.Items
43+
case "properties":
44+
schema = schema.Properties[chunks[i+1]]
45+
i++
46+
default:
47+
return nil, fmt.Errorf("unknown schema path %v: %s", chunks, k)
48+
}
49+
}
50+
3351
if schema == nil {
3452
return nil, fmt.Errorf("schema %q not found", path)
3553
}

0 commit comments

Comments
 (0)