diff --git a/docs/docs.go b/docs/docs.go index 8f175707..a74d8b0b 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -7413,8 +7413,7 @@ const docTemplate = `{ "type": "object", "properties": { "avg": { - "type": "integer", - "format": "uint64" + "type": "number" }, "cur": { "type": "integer", @@ -7451,8 +7450,7 @@ const docTemplate = `{ "type": "object", "properties": { "avg": { - "type": "integer", - "format": "uint64" + "type": "number" }, "cur": { "type": "integer", diff --git a/docs/swagger.json b/docs/swagger.json index 448d8718..54e8532c 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -7406,8 +7406,7 @@ "type": "object", "properties": { "avg": { - "type": "integer", - "format": "uint64" + "type": "number" }, "cur": { "type": "integer", @@ -7444,8 +7443,7 @@ "type": "object", "properties": { "avg": { - "type": "integer", - "format": "uint64" + "type": "number" }, "cur": { "type": "integer", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 5e3730cf..e5ada02e 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1586,8 +1586,7 @@ definitions: api.ProcessUsageGPUMemory: properties: avg: - format: uint64 - type: integer + type: number cur: format: uint64 type: integer @@ -1612,8 +1611,7 @@ definitions: api.ProcessUsageMemory: properties: avg: - format: uint64 - type: integer + type: number cur: format: uint64 type: integer diff --git a/http/api/process.go b/http/api/process.go index c7cae209..ce418a9e 100644 --- a/http/api/process.go +++ b/http/api/process.go @@ -431,15 +431,15 @@ func (p *ProcessUsageCPU) Marshal() app.ProcessUsageCPU { } type ProcessUsageMemory struct { - Current uint64 `json:"cur" format:"uint64"` - Average uint64 `json:"avg" format:"uint64"` - Max uint64 `json:"max" format:"uint64"` - Limit uint64 `json:"limit" format:"uint64"` + Current uint64 `json:"cur" format:"uint64"` + Average json.Number `json:"avg" swaggertype:"number" jsonschema:"type=number"` + Max uint64 `json:"max" format:"uint64"` + Limit uint64 `json:"limit" format:"uint64"` } func (p *ProcessUsageMemory) Unmarshal(pp *app.ProcessUsageMemory) { p.Current = pp.Current - p.Average = pp.Average + p.Average = json.ToNumber(float64(pp.Average)) p.Max = pp.Max p.Limit = pp.Limit } @@ -447,24 +447,27 @@ func (p *ProcessUsageMemory) Unmarshal(pp *app.ProcessUsageMemory) { func (p *ProcessUsageMemory) Marshal() app.ProcessUsageMemory { pp := app.ProcessUsageMemory{ Current: p.Current, - Average: p.Average, Max: p.Max, Limit: p.Limit, } + if x, err := p.Average.Float64(); err == nil { + pp.Average = uint64(x) + } + return pp } type ProcessUsageGPUMemory struct { - Current uint64 `json:"cur" format:"uint64"` - Average uint64 `json:"avg" format:"uint64"` - Max uint64 `json:"max" format:"uint64"` - Limit uint64 `json:"limit" format:"uint64"` + Current uint64 `json:"cur" format:"uint64"` + Average json.Number `json:"avg" swaggertype:"number" jsonschema:"type=number"` + Max uint64 `json:"max" format:"uint64"` + Limit uint64 `json:"limit" format:"uint64"` } func (p *ProcessUsageGPUMemory) Unmarshal(pp *app.ProcessUsageGPUMemory) { p.Current = pp.Current - p.Average = pp.Average + p.Average = json.ToNumber(float64(pp.Average)) p.Max = pp.Max p.Limit = pp.Limit } @@ -472,11 +475,14 @@ func (p *ProcessUsageGPUMemory) Unmarshal(pp *app.ProcessUsageGPUMemory) { func (p *ProcessUsageGPUMemory) Marshal() app.ProcessUsageGPUMemory { pp := app.ProcessUsageGPUMemory{ Current: p.Current, - Average: p.Average, Max: p.Max, Limit: p.Limit, } + if x, err := p.Average.Float64(); err == nil { + pp.Average = uint64(x) + } + return pp }