Skip to content

Commit

Permalink
feat: openapi3edit: add OperationMore.AddToSpec()
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed Oct 19, 2022
1 parent 19b1026 commit 6a300a9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions openapi3edit/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ func (opm *OperationMore) HasParameter(paramNameWant string) bool {
return false
}

func (opm *OperationMore) AddToSpec(spec *openapi3.Spec, force bool) (bool, error) {
sm := openapi3.SpecMore{Spec: spec}
op, err := sm.OperationByPathMethod(opm.Path, opm.Method)
if err != nil {
return false, err
}
if op == nil || force {
spec.AddOperation(opm.Path, opm.Method, opm.Operation)
return true, nil
}
return false, nil
}

func operationAddRequestBodySchemaRef(op *oas3.Operation, description string, required bool, contentType string, schemaRef *oas3.SchemaRef) error {
if op == nil {
return fmt.Errorf("operation to edit is nil")
Expand Down

0 comments on commit 6a300a9

Please sign in to comment.