diff --git a/addon/client.go b/addon/client.go index c2946d3b..23ce2994 100644 --- a/addon/client.go +++ b/addon/client.go @@ -185,6 +185,7 @@ func (r *Client) Post(path string, object interface{}) (err error) { err = liberr.Wrap(err) return } + case http.StatusNoContent: case http.StatusConflict: err = &Conflict{Path: path} default: diff --git a/api/analysis.go b/api/analysis.go index 6f72478c..098852cb 100644 --- a/api/analysis.go +++ b/api/analysis.go @@ -169,9 +169,9 @@ func (h AnalysisHandler) AppList(ctx *gin.Context) { // @tags analyses // @accept json // @produce json -// @success 201 {object} api.Analysis +// @success 204 // @router /application/{id}/analyses [post] -// @param task body api.Analysis true "Analysis data" +// @param manifest body api.AnalysisManifest true "AnalysisManifest data" func (h AnalysisHandler) AppCreate(ctx *gin.Context) { id := h.pk(ctx) r := &Analysis{} @@ -276,17 +276,8 @@ func (h AnalysisHandler) AppCreate(ctx *gin.Context) { return } } - // - // Fetch. - db = h.preLoad(h.DB(ctx), clause.Associations) - result := db.First(analysis, analysis.ID) - if result.Error != nil { - _ = ctx.Error(result.Error) - return - } - r.With(analysis) - h.Respond(ctx, http.StatusCreated, r) + h.Status(ctx, http.StatusNoContent) } // Delete godoc diff --git a/binding/client.go b/binding/client.go index 2414334c..45b69919 100644 --- a/binding/client.go +++ b/binding/client.go @@ -186,6 +186,7 @@ func (r *Client) Post(path string, object interface{}) (err error) { err = liberr.Wrap(err) return } + case http.StatusNoContent: case http.StatusConflict: err = &Conflict{Path: path} default: diff --git a/docs/docs.go b/docs/docs.go index c5d86e58..94282277 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -343,21 +343,18 @@ const docTemplate = `{ "summary": "Create an analysis.", "parameters": [ { - "description": "Analysis data", - "name": "task", + "description": "AnalysisManifest data", + "name": "manifest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/api.Analysis" + "$ref": "#/definitions/api.AnalysisManifest" } } ], "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/api.Analysis" - } + "204": { + "description": "No Content" } } } @@ -4540,6 +4537,29 @@ const docTemplate = `{ } } }, + "api.AnalysisManifest": { + "type": "object", + "properties": { + "createTime": { + "type": "string" + }, + "createUser": { + "type": "string" + }, + "dependencies": { + "$ref": "#/definitions/api.Ref" + }, + "id": { + "type": "integer" + }, + "issues": { + "$ref": "#/definitions/api.Ref" + }, + "updateUser": { + "type": "string" + } + } + }, "api.Application": { "type": "object", "required": [ @@ -5297,7 +5317,7 @@ const docTemplate = `{ "rule": { "type": "string" }, - "ruleSet": { + "ruleset": { "type": "string" } } diff --git a/docs/swagger.json b/docs/swagger.json index 6d935586..e4391bc5 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -331,21 +331,18 @@ "summary": "Create an analysis.", "parameters": [ { - "description": "Analysis data", - "name": "task", + "description": "AnalysisManifest data", + "name": "manifest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/api.Analysis" + "$ref": "#/definitions/api.AnalysisManifest" } } ], "responses": { - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/api.Analysis" - } + "204": { + "description": "No Content" } } } @@ -4528,6 +4525,29 @@ } } }, + "api.AnalysisManifest": { + "type": "object", + "properties": { + "createTime": { + "type": "string" + }, + "createUser": { + "type": "string" + }, + "dependencies": { + "$ref": "#/definitions/api.Ref" + }, + "id": { + "type": "integer" + }, + "issues": { + "$ref": "#/definitions/api.Ref" + }, + "updateUser": { + "type": "string" + } + } + }, "api.Application": { "type": "object", "required": [ @@ -5285,7 +5305,7 @@ "rule": { "type": "string" }, - "ruleSet": { + "ruleset": { "type": "string" } } diff --git a/docs/swagger.yaml b/docs/swagger.yaml index b907a275..f8e88fc6 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -25,6 +25,21 @@ definitions: updateUser: type: string type: object + api.AnalysisManifest: + properties: + createTime: + type: string + createUser: + type: string + dependencies: + $ref: '#/definitions/api.Ref' + id: + type: integer + issues: + $ref: '#/definitions/api.Ref' + updateUser: + type: string + type: object api.Application: properties: binary: @@ -527,7 +542,7 @@ definitions: type: string rule: type: string - ruleSet: + ruleset: type: string type: object api.RuleSet: @@ -1187,19 +1202,17 @@ paths: An issues file that multiple issue resources. A dependencies file that contains an array of dependencies. parameters: - - description: Analysis data + - description: AnalysisManifest data in: body - name: task + name: manifest required: true schema: - $ref: '#/definitions/api.Analysis' + $ref: '#/definitions/api.AnalysisManifest' produces: - application/json responses: - "201": - description: Created - schema: - $ref: '#/definitions/api.Analysis' + "204": + description: No Content summary: Create an analysis. tags: - analyses