diff --git a/pkg/concepts/method.go b/pkg/concepts/method.go index e68b373..9b78198 100644 --- a/pkg/concepts/method.go +++ b/pkg/concepts/method.go @@ -86,6 +86,11 @@ func (m *Method) IsDelete() bool { return m.name.Equals(nomenclator.Delete) } +// IsAsyncDelete return true if this is an asynchronous add method. +func (m *Method) IsAsyncDelete() bool { + return m.name.Equals(nomenclator.AsyncDelete) +} + // IsGet returns true if this is a get method. func (m *Method) IsGet() bool { return m.name.Equals(nomenclator.Get) @@ -111,6 +116,11 @@ func (m *Method) IsUpdate() bool { return m.name.Equals(nomenclator.Update) } +// IsAsyncUpdate returns true if this is an asynchronous update method. +func (m *Method) IsAsyncUpdate() bool { + return m.name.Equals(nomenclator.AsyncUpdate) +} + // IsAction determined if this method is an action instead of a regular REST method. func (m *Method) IsAction() bool { switch { @@ -118,6 +128,8 @@ func (m *Method) IsAction() bool { return false case m.IsDelete(): return false + case m.IsAsyncDelete(): + return false case m.IsGet(): return false case m.IsList(): @@ -128,6 +140,8 @@ func (m *Method) IsAction() bool { return false case m.IsUpdate(): return false + case m.IsAsyncUpdate(): + return false default: return true } diff --git a/pkg/concepts/parameter.go b/pkg/concepts/parameter.go index 58aa82a..2c6009f 100644 --- a/pkg/concepts/parameter.go +++ b/pkg/concepts/parameter.go @@ -89,7 +89,7 @@ func (p *Parameter) IsBody() bool { if p.owner == nil { return false } - isRest := p.owner.IsAdd() || p.owner.IsGet() || p.owner.IsSearch() || p.owner.IsUpdate() + isRest := p.owner.IsAdd() || p.owner.IsGet() || p.owner.IsSearch() || p.owner.IsUpdate() || p.owner.IsAsyncUpdate() if isRest && p.name.Equals(nomenclator.Body) { return true } diff --git a/pkg/generators/docs/docs_generator.go b/pkg/generators/docs/docs_generator.go index 10e40d8..1b4233e 100644 --- a/pkg/generators/docs/docs_generator.go +++ b/pkg/generators/docs/docs_generator.go @@ -385,10 +385,10 @@ func (g *DocsGenerator) httpMethod(method *concepts.Method) string { if name.Equals(nomenclator.Add) { return "POST" } - if name.Equals(nomenclator.Update) { + if name.Equals(nomenclator.Update) || name.Equals(nomenclator.AsyncUpdate) { return "PATCH" } - if name.Equals(nomenclator.Delete) { + if name.Equals(nomenclator.Delete) || name.Equals(nomenclator.AsyncDelete) { return "DELETE" } return "POST" diff --git a/pkg/generators/golang/json_generator.go b/pkg/generators/golang/json_generator.go index 018db16..9c86f20 100644 --- a/pkg/generators/golang/json_generator.go +++ b/pkg/generators/golang/json_generator.go @@ -838,7 +838,7 @@ func (g *JSONSupportGenerator) generateMethodSource(method *concepts.Method) { switch { case method.IsAdd(): g.generateAddMethodSource(method) - case method.IsDelete(): + case method.IsDelete() || method.IsAsyncDelete(): g.generateDeleteMethodSource(method) case method.IsGet(): g.generateGetMethodSource(method) @@ -848,7 +848,7 @@ func (g *JSONSupportGenerator) generateMethodSource(method *concepts.Method) { g.generatePostMethodSource(method) case method.IsSearch(): g.generateSearchMethodSource(method) - case method.IsUpdate(): + case method.IsUpdate() || method.IsAsyncUpdate(): g.generateUpdateMethodSource(method) case method.IsAction(): g.generateActionMethodSource(method) diff --git a/pkg/http/binding_calculator.go b/pkg/http/binding_calculator.go index 73cbaac..dd09956 100644 --- a/pkg/http/binding_calculator.go +++ b/pkg/http/binding_calculator.go @@ -148,7 +148,7 @@ func (c *BindingCalculator) Method(method *concepts.Method) string { switch { case name.Equals(nomenclator.Add): return http.MethodPost - case name.Equals(nomenclator.Delete): + case name.Equals(nomenclator.Delete) || name.Equals(nomenclator.AsyncDelete): return http.MethodDelete case name.Equals(nomenclator.Get): return http.MethodGet @@ -156,7 +156,7 @@ func (c *BindingCalculator) Method(method *concepts.Method) string { return http.MethodGet case name.Equals(nomenclator.Post): return http.MethodPost - case name.Equals(nomenclator.Update): + case name.Equals(nomenclator.Update) || name.Equals(nomenclator.AsyncUpdate): return http.MethodPatch default: return http.MethodPost @@ -173,10 +173,14 @@ func (c *BindingCalculator) DefaultStatus(method *concepts.Method) string { status = http.StatusCreated case name.Equals(nomenclator.Add): status = http.StatusCreated + case name.Equals(nomenclator.AsyncUpdate): + status = http.StatusCreated case name.Equals(nomenclator.Update): status = http.StatusOK case name.Equals(nomenclator.Delete): status = http.StatusNoContent + case name.Equals(nomenclator.AsyncDelete): + status = http.StatusAccepted } return strconv.Itoa(status) } diff --git a/pkg/language/checks.go b/pkg/language/checks.go index 31fc7f9..28c71b3 100644 --- a/pkg/language/checks.go +++ b/pkg/language/checks.go @@ -62,7 +62,7 @@ func (r *Reader) checkMethod(method *concepts.Method) { switch { case method.IsAdd(): r.checkAdd(method) - case method.IsDelete(): + case method.IsDelete() || method.IsAsyncDelete(): r.checkDelete(method) case method.IsGet(): r.checkGet(method) @@ -72,7 +72,7 @@ func (r *Reader) checkMethod(method *concepts.Method) { r.checkPost(method) case method.IsSearch(): r.checkSearch(method) - case method.IsUpdate(): + case method.IsUpdate() || method.IsAsyncUpdate(): r.checkUpdate(method) case method.IsAction(): r.checkAction(method) diff --git a/pkg/nomenclator/names.go b/pkg/nomenclator/names.go index b6dfc65..abb87c2 100644 --- a/pkg/nomenclator/names.go +++ b/pkg/nomenclator/names.go @@ -22,9 +22,11 @@ import ( var ( // A: - Adapt = names.ParseUsingCase("Adapt") - Adapter = names.ParseUsingCase("Adapter") - Add = names.ParseUsingCase("Add") + Adapt = names.ParseUsingCase("Adapt") + Adapter = names.ParseUsingCase("Adapter") + Add = names.ParseUsingCase("Add") + AsyncDelete = names.ParseUsingCase("AsyncDelete") + AsyncUpdate = names.ParseUsingCase("AsyncUpdate") // B: Body = names.ParseUsingCase("Body")