Skip to content

Commit

Permalink
refactor: merge serviceuser in service module
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov committed Oct 7, 2024
1 parent 907258e commit 6ce48df
Show file tree
Hide file tree
Showing 6 changed files with 344 additions and 695 deletions.
4 changes: 0 additions & 4 deletions client_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ Service:
- ServiceTaskCreate
- ServiceTaskGet
- ServiceUpdate
ServiceUser:
- ServiceUserCreate
- ServiceUserCredentialsModify
- ServiceUserCredentialsReset
Expand Down
20 changes: 19 additions & 1 deletion generator/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,28 @@ type Doc struct {
} `json:"components"`
}

const componentIndex = 3

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

name := chunks[componentIndex]
schema := d.Components.Schemas[name]
for i := componentIndex + 1; i < len(chunks); i++ {
switch k := chunks[i]; k {
case "items":
schema = schema.Items
case "properties":
schema = schema.Properties[chunks[i+1]]
i++
default:
return nil, fmt.Errorf("unknown schema path %v: %s", chunks, k)
}
}

if schema == nil {
return nil, fmt.Errorf("schema %q not found", path)
}
Expand Down
Loading

0 comments on commit 6ce48df

Please sign in to comment.