diff --git a/.golangci.yml b/.golangci.yml index 1134cf52..de6c26a9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,12 +10,15 @@ linters: - dupl # generated code has a lot of duplication - err113 # generated code does not wrap errors - exhaustruct # generated code does not initialize all fields + - forbidigo # in examples, we have a lot of printing and logging on purpose - funlen # generated code produces long functions - gochecknoglobals # generated code uses globals - gochecknoinits # generated code uses init() - gocognit # generated code has high cognitive complexity - gocyclo # generated code has high cyclomatic complexity - godox # allow TODOs + - gomodguard # deprecated + - gomodguard_v2 # we don't use this - ireturn # generated code returns interfaces - lll # generated code has long lines - maintidx # generated code has low maintainability index @@ -26,6 +29,7 @@ linters: - noinlineerr # unclear added value - paralleltest # no test files - recvcheck # disagree + - tagalign # generated tags for jesssevdk CLI trigger this. To be investigated further (non-blocking) - tagliatelle # false positives on generated tags - testpackage # no test files - thelper # no test files @@ -46,6 +50,9 @@ linters: goconst: min-len: 2 min-occurrences: 3 + gosec: + excludes: + - G706 # logs in examples are deliberately verbose and revealing of the internals exclusions: warn-unused: false generated: lax diff --git a/2.0/petstore/server/api/petstore.go b/2.0/petstore/server/api/petstore.go index 423eb796..16848d0d 100644 --- a/2.0/petstore/server/api/petstore.go +++ b/2.0/petstore/server/api/petstore.go @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//nolint:forcetypeassert // type assertions left unchecked for brevity package api import ( @@ -26,10 +27,10 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/runtime/middleware/untyped" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) -// NewPetstore creates a new petstore api handler +// NewPetstore creates a new petstore api handler. func NewPetstore() (http.Handler, error) { spec, err := loads.Analyzed(json.RawMessage([]byte(swaggerJSON)), "") if err != nil { @@ -56,7 +57,7 @@ var createPet = runtime.OperationHandlerFunc(func(data any) (any, error) { fmt.Printf("%#v\n", data) body := data.(map[string]any)["pet"] var pet Pet - if err := swag.FromDynamicJSON(body, &pet); err != nil { + if err := jsonutils.FromDynamicJSON(body, &pet); err != nil { return nil, err } addPet(pet) @@ -68,7 +69,8 @@ var deletePet = runtime.OperationHandlerFunc(func(data any) (any, error) { fmt.Printf("%#v\n", data) id := data.(map[string]any)["id"].(int64) removePet(id) - return nil, nil + + return nil, nil //nolint:nilnil // for demo purpose we don't return any response }) var getPetByID = runtime.OperationHandlerFunc(func(data any) (any, error) { @@ -78,13 +80,13 @@ var getPetByID = runtime.OperationHandlerFunc(func(data any) (any, error) { return petByID(id) }) -// Tag the tag model +// Tag the tag model. type Tag struct { ID int64 Name string } -// Pet the pet model +// Pet the pet model. type Pet struct { ID int64 `json:"id"` Name string `json:"name"` diff --git a/README.md b/README.md index 3c549420..113e0613 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,22 @@ This software ships under the [SPDX-License-Identifier: Apache-2.0](./LICENSE). * [Contributing guidelines](.github/CONTRIBUTING.md) * [Code style](docs/STYLE.md) +## Regenerating all examples + +``` +go run ./hack/tools regen +``` + +To run examples, some of these require some auth material (not committed to this repo): +``` +go run ./hack/tools gencerts +go run ./hack/tools gentokens +``` + +## Cutting a new release + +This repository is deliberately left unreleased: examples follow the code generation on go-swagger/go-swagger@master. + [test-badge]: https://github.com/go-swagger/examples/actions/workflows/go-test.yml/badge.svg [test-url]: https://github.com/go-swagger/examples/actions/workflows/go-test.yml diff --git a/alias-compatibility/api.go b/alias-compatibility/api.go index b8dcc0bd..ccbd5f1b 100644 --- a/alias-compatibility/api.go +++ b/alias-compatibility/api.go @@ -33,13 +33,13 @@ // swagger:meta package demo -// Identifier represents a unique identifier +// Identifier represents a unique identifier. type Identifier string -// UserID is an alias to Identifier for user-specific IDs +// UserID is an alias to Identifier for user-specific IDs. type UserID = Identifier -// User represents a user in the system +// User represents a user in the system. type User struct { ID UserID `json:"id"` Name string `json:"name"` @@ -60,4 +60,4 @@ type UserResponse struct { // Responses: // // 200: UserResponse -func getUser() {} +func getUser() {} //nolint:unused // left here to demonstrate what we get from an unexported symbol diff --git a/authentication/client/auth_sample_client.go b/authentication/client/auth_sample_client.go index 8b22b43d..7947c31e 100644 --- a/authentication/client/auth_sample_client.go +++ b/authentication/client/auth_sample_client.go @@ -6,7 +6,6 @@ import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/authentication/client/customers" ) diff --git a/authentication/client/customers/create_parameters.go b/authentication/client/customers/create_parameters.go index bd6a67df..d552821b 100644 --- a/authentication/client/customers/create_parameters.go +++ b/authentication/client/customers/create_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/authentication/models" ) diff --git a/authentication/client/customers/create_responses.go b/authentication/client/customers/create_responses.go index d52b4b76..28d47cce 100644 --- a/authentication/client/customers/create_responses.go +++ b/authentication/client/customers/create_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/authentication/models" ) diff --git a/authentication/client/customers/get_id_parameters.go b/authentication/client/customers/get_id_parameters.go index 038faff7..1053aa19 100644 --- a/authentication/client/customers/get_id_parameters.go +++ b/authentication/client/customers/get_id_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/authentication/models" ) diff --git a/authentication/client/customers/get_id_responses.go b/authentication/client/customers/get_id_responses.go index 184dcbcb..cdaa4d14 100644 --- a/authentication/client/customers/get_id_responses.go +++ b/authentication/client/customers/get_id_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/authentication/models" ) diff --git a/authentication/models/customer.go b/authentication/models/customer.go index 79b0f1c8..381d0c79 100644 --- a/authentication/models/customer.go +++ b/authentication/models/customer.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -164,13 +164,13 @@ func (m *Customer) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Customer) UnmarshalBinary(b []byte) error { var res Customer - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/authentication/models/error.go b/authentication/models/error.go index 4102bd38..35003bc7 100644 --- a/authentication/models/error.go +++ b/authentication/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -60,13 +60,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/authentication/models/social_id.go b/authentication/models/social_id.go index df0a5d62..3e231b7e 100644 --- a/authentication/models/social_id.go +++ b/authentication/models/social_id.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -59,13 +59,13 @@ func (m *SocialID) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *SocialID) UnmarshalBinary(b []byte) error { var res SocialID - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/authentication/restapi/configure_auth_sample.go b/authentication/restapi/configure_auth_sample.go index 771c15a2..9825b8e8 100644 --- a/authentication/restapi/configure_auth_sample.go +++ b/authentication/restapi/configure_auth_sample.go @@ -18,7 +18,7 @@ import ( //go:generate swagger generate server --target ../../authentication --name AuthSample --spec ../swagger.yml --principal models.Principal func configureFlags(api *operations.AuthSampleAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/authentication/restapi/operations/auth_sample_api.go b/authentication/restapi/operations/auth_sample_api.go index 6f04e216..cea17ba4 100644 --- a/authentication/restapi/operations/auth_sample_api.go +++ b/authentication/restapi/operations/auth_sample_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/authentication/models" "github.com/go-swagger/examples/authentication/restapi/operations/customers" @@ -125,7 +125,7 @@ type AuthSampleAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/authentication/restapi/operations/customers/create_responses.go b/authentication/restapi/operations/customers/create_responses.go index cce53826..bd98ca09 100644 --- a/authentication/restapi/operations/customers/create_responses.go +++ b/authentication/restapi/operations/customers/create_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/authentication/models" ) diff --git a/authentication/restapi/operations/customers/get_id_responses.go b/authentication/restapi/operations/customers/get_id_responses.go index 6586b3bc..abecd467 100644 --- a/authentication/restapi/operations/customers/get_id_responses.go +++ b/authentication/restapi/operations/customers/get_id_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/authentication/models" ) diff --git a/authentication/restapi/server.go b/authentication/restapi/server.go index bed7f430..2a34ceff 100644 --- a/authentication/restapi/server.go +++ b/authentication/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/authentication/restapi/operations" ) @@ -368,7 +368,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -383,7 +383,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/auto-configure/implementation/auth_impl.go b/auto-configure/implementation/auth_impl.go index 169cc5f0..d23d38f9 100644 --- a/auto-configure/implementation/auth_impl.go +++ b/auto-configure/implementation/auth_impl.go @@ -9,6 +9,6 @@ func (i *AuthImpl) KeyAuth(token string) (any, error) { return nil, errors.New("wrong token") } - // if return nil, nil, will cause 401 error + // if return nil value, will cause 401 error return true, nil } diff --git a/auto-configure/implementation/configure_impl.go b/auto-configure/implementation/configure_impl.go index 7867a3e0..b80c3ff4 100644 --- a/auto-configure/implementation/configure_impl.go +++ b/auto-configure/implementation/configure_impl.go @@ -5,7 +5,7 @@ import ( "log" "net/http" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/auto-configure/restapi/operations" ) @@ -20,7 +20,7 @@ type Flags struct { } func (i *ConfigureImpl) ConfigureFlags(api *operations.AToDoListApplicationAPI) { - api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ + api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ { ShortDescription: "Example Flags", LongDescription: "", diff --git a/auto-configure/implementation/handler.go b/auto-configure/implementation/handler.go index c9ffa097..2571d1e7 100644 --- a/auto-configure/implementation/handler.go +++ b/auto-configure/implementation/handler.go @@ -7,7 +7,7 @@ import ( ) // HandlerImpl implements all required configuration and api handling -// functionalities for todo list server backend +// functionalities for todo list server backend. type HandlerImpl struct { TodosHandlerImpl ConfigureImpl diff --git a/auto-configure/implementation/todos_impl.go b/auto-configure/implementation/todos_impl.go index c6e25a2d..a3b79cf0 100644 --- a/auto-configure/implementation/todos_impl.go +++ b/auto-configure/implementation/todos_impl.go @@ -6,7 +6,7 @@ import ( "sync" "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-swagger/examples/auto-configure/models" "github.com/go-swagger/examples/auto-configure/restapi/operations/todos" @@ -63,7 +63,7 @@ func (i *TodosHandlerImpl) FindTodos(params todos.FindTodosParams, principal any i.lock.Lock() defer i.lock.Unlock() mergedParams := todos.NewFindTodosParams() - mergedParams.Since = swag.Int64(0) + mergedParams.Since = conv.Pointer(int64(0)) if params.Since != nil { mergedParams.Since = params.Since } diff --git a/auto-configure/models/error.go b/auto-configure/models/error.go index 181b96a9..bac28f38 100644 --- a/auto-configure/models/error.go +++ b/auto-configure/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/auto-configure/models/item.go b/auto-configure/models/item.go index 2e517784..2e163a96 100644 --- a/auto-configure/models/item.go +++ b/auto-configure/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/auto-configure/restapi/operations/a_to_do_list_application_api.go b/auto-configure/restapi/operations/a_to_do_list_application_api.go index be65dacc..68a08b5a 100644 --- a/auto-configure/restapi/operations/a_to_do_list_application_api.go +++ b/auto-configure/restapi/operations/a_to_do_list_application_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/auto-configure/restapi/operations/todos" ) @@ -142,7 +142,7 @@ type AToDoListApplicationAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/auto-configure/restapi/operations/todos/add_one_responses.go b/auto-configure/restapi/operations/todos/add_one_responses.go index 00408896..6ec83fb4 100644 --- a/auto-configure/restapi/operations/todos/add_one_responses.go +++ b/auto-configure/restapi/operations/todos/add_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/auto-configure/models" ) diff --git a/auto-configure/restapi/operations/todos/destroy_one_parameters.go b/auto-configure/restapi/operations/todos/destroy_one_parameters.go index 3322808a..ab647b06 100644 --- a/auto-configure/restapi/operations/todos/destroy_one_parameters.go +++ b/auto-configure/restapi/operations/todos/destroy_one_parameters.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewDestroyOneParams creates a new DestroyOneParams object @@ -63,7 +63,7 @@ func (o *DestroyOneParams) bindID(rawData []string, hasKey bool, formats strfmt. // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("id", "path", "int64", raw) } diff --git a/auto-configure/restapi/operations/todos/destroy_one_responses.go b/auto-configure/restapi/operations/todos/destroy_one_responses.go index bbb9cda0..d9004687 100644 --- a/auto-configure/restapi/operations/todos/destroy_one_responses.go +++ b/auto-configure/restapi/operations/todos/destroy_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/auto-configure/models" ) diff --git a/auto-configure/restapi/operations/todos/destroy_one_urlbuilder.go b/auto-configure/restapi/operations/todos/destroy_one_urlbuilder.go index fa4417ce..975fbefc 100644 --- a/auto-configure/restapi/operations/todos/destroy_one_urlbuilder.go +++ b/auto-configure/restapi/operations/todos/destroy_one_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // DestroyOneURL generates an URL for the destroy one operation @@ -41,7 +41,7 @@ func (o *DestroyOneURL) Build() (*url.URL, error) { var _path = "/{id}" - id := swag.FormatInt64(o.ID) + id := conv.FormatInteger(o.ID) if id != "" { _path = strings.ReplaceAll(_path, "{id}", id) } else { diff --git a/auto-configure/restapi/operations/todos/find_todos_parameters.go b/auto-configure/restapi/operations/todos/find_todos_parameters.go index 3472ad6f..8fbe147d 100644 --- a/auto-configure/restapi/operations/todos/find_todos_parameters.go +++ b/auto-configure/restapi/operations/todos/find_todos_parameters.go @@ -9,7 +9,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewFindTodosParams creates a new FindTodosParams object @@ -87,7 +87,7 @@ func (o *FindTodosParams) bindLimit(rawData []string, hasKey bool, formats strfm return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "query", "int32", raw) } @@ -110,7 +110,7 @@ func (o *FindTodosParams) bindSince(rawData []string, hasKey bool, formats strfm return nil } - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("since", "query", "int64", raw) } diff --git a/auto-configure/restapi/operations/todos/find_todos_responses.go b/auto-configure/restapi/operations/todos/find_todos_responses.go index 586c1c5c..2e847d63 100644 --- a/auto-configure/restapi/operations/todos/find_todos_responses.go +++ b/auto-configure/restapi/operations/todos/find_todos_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/auto-configure/models" ) diff --git a/auto-configure/restapi/operations/todos/find_todos_urlbuilder.go b/auto-configure/restapi/operations/todos/find_todos_urlbuilder.go index 825eeb4e..5472135f 100644 --- a/auto-configure/restapi/operations/todos/find_todos_urlbuilder.go +++ b/auto-configure/restapi/operations/todos/find_todos_urlbuilder.go @@ -7,7 +7,7 @@ import ( "net/url" golangswaggerpaths "path" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // FindTodosURL generates an URL for the find todos operation @@ -48,7 +48,7 @@ func (o *FindTodosURL) Build() (*url.URL, error) { var limitQ string if o.Limit != nil { - limitQ = swag.FormatInt32(*o.Limit) + limitQ = conv.FormatInteger(*o.Limit) } if limitQ != "" { qs.Set("limit", limitQ) @@ -56,7 +56,7 @@ func (o *FindTodosURL) Build() (*url.URL, error) { var sinceQ string if o.Since != nil { - sinceQ = swag.FormatInt64(*o.Since) + sinceQ = conv.FormatInteger(*o.Since) } if sinceQ != "" { qs.Set("since", sinceQ) diff --git a/auto-configure/restapi/operations/todos/update_one_parameters.go b/auto-configure/restapi/operations/todos/update_one_parameters.go index f0b06dc8..f5790a3d 100644 --- a/auto-configure/restapi/operations/todos/update_one_parameters.go +++ b/auto-configure/restapi/operations/todos/update_one_parameters.go @@ -9,7 +9,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" "github.com/go-swagger/examples/auto-configure/models" @@ -96,7 +96,7 @@ func (o *UpdateOneParams) bindID(rawData []string, hasKey bool, formats strfmt.R // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("id", "path", "int64", raw) } diff --git a/auto-configure/restapi/operations/todos/update_one_responses.go b/auto-configure/restapi/operations/todos/update_one_responses.go index 51f67d4d..6e8959ec 100644 --- a/auto-configure/restapi/operations/todos/update_one_responses.go +++ b/auto-configure/restapi/operations/todos/update_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/auto-configure/models" ) diff --git a/auto-configure/restapi/operations/todos/update_one_urlbuilder.go b/auto-configure/restapi/operations/todos/update_one_urlbuilder.go index 745deca3..1eb25473 100644 --- a/auto-configure/restapi/operations/todos/update_one_urlbuilder.go +++ b/auto-configure/restapi/operations/todos/update_one_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // UpdateOneURL generates an URL for the update one operation @@ -41,7 +41,7 @@ func (o *UpdateOneURL) Build() (*url.URL, error) { var _path = "/{id}" - id := swag.FormatInt64(o.ID) + id := conv.FormatInteger(o.ID) if id != "" { _path = strings.ReplaceAll(_path, "{id}", id) } else { diff --git a/auto-configure/restapi/server.go b/auto-configure/restapi/server.go index 1031da4b..29a7987b 100644 --- a/auto-configure/restapi/server.go +++ b/auto-configure/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/auto-configure/restapi/operations" ) @@ -368,7 +368,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -383,7 +383,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/cli/cli/add_one_operation.go b/cli/cli/add_one_operation.go index fd8bad2f..998c1f6e 100644 --- a/cli/cli/add_one_operation.go +++ b/cli/cli/add_one_operation.go @@ -6,12 +6,11 @@ import ( "encoding/json" "fmt" + "github.com/go-openapi/swag/typeutils" "github.com/go-swagger/examples/cli/client/todos" "github.com/go-swagger/examples/cli/models" "github.com/spf13/cobra" - - "github.com/go-openapi/swag" ) // makeOperationTodosAddOneCmd returns a command to handle operation addOne @@ -100,7 +99,7 @@ func retrieveOperationTodosAddOneBodyFlag(m *todos.AddOneParams, cmdPrefix strin m.Body = &flagBodyValue } flagBodyModel := m.Body - if swag.IsZero(flagBodyModel) { + if typeutils.IsZero(flagBodyModel) { flagBodyModel = &models.Item{} } err, added := retrieveModelItemFlags(0, flagBodyModel, "item", cmd) @@ -131,7 +130,7 @@ func parseOperationTodosAddOneResult(resp0 *todos.AddOneCreated, respErr error) var iRespD any = respErr respD, ok := iRespD.(*todos.AddOneDefault) if ok { - if !swag.IsZero(respD) && !swag.IsZero(respD.Payload) { + if !typeutils.IsZero(respD) && !typeutils.IsZero(respD.Payload) { msgStr, err := json.Marshal(respD.Payload) if err != nil { return "", err @@ -145,7 +144,7 @@ func parseOperationTodosAddOneResult(resp0 *todos.AddOneCreated, respErr error) eresp0, ok := iResp0.(*todos.AddOneCreated) if ok { // the error response has a payload - if !swag.IsZero(eresp0) && !swag.IsZero(eresp0.Payload) { + if !typeutils.IsZero(eresp0) && !typeutils.IsZero(eresp0.Payload) { msgStr, err := json.Marshal(eresp0.Payload) if err != nil { return "", err @@ -157,7 +156,7 @@ func parseOperationTodosAddOneResult(resp0 *todos.AddOneCreated, respErr error) } // success responses - if !swag.IsZero(resp0) && !swag.IsZero(resp0.Payload) { + if !typeutils.IsZero(resp0) && !typeutils.IsZero(resp0.Payload) { msgStr, err := json.Marshal(resp0.Payload) if err != nil { return "", err diff --git a/cli/cli/destroy_one_operation.go b/cli/cli/destroy_one_operation.go index 29fb0f32..ee17b466 100644 --- a/cli/cli/destroy_one_operation.go +++ b/cli/cli/destroy_one_operation.go @@ -6,11 +6,10 @@ import ( "encoding/json" "fmt" + "github.com/go-openapi/swag/typeutils" "github.com/go-swagger/examples/cli/client/todos" "github.com/spf13/cobra" - - "github.com/go-openapi/swag" ) // makeOperationTodosDestroyOneCmd returns a command to handle operation destroyOne @@ -111,7 +110,7 @@ func parseOperationTodosDestroyOneResult(resp0 *todos.DestroyOneNoContent, respE var iRespD any = respErr respD, ok := iRespD.(*todos.DestroyOneDefault) if ok { - if !swag.IsZero(respD) && !swag.IsZero(respD.Payload) { + if !typeutils.IsZero(respD) && !typeutils.IsZero(respD.Payload) { msgStr, err := json.Marshal(respD.Payload) if err != nil { return "", err diff --git a/cli/cli/find_todos_operation.go b/cli/cli/find_todos_operation.go index d49ce0da..2aa4775b 100644 --- a/cli/cli/find_todos_operation.go +++ b/cli/cli/find_todos_operation.go @@ -6,11 +6,10 @@ import ( "encoding/json" "fmt" + "github.com/go-openapi/swag/typeutils" "github.com/go-swagger/examples/cli/client/todos" "github.com/spf13/cobra" - - "github.com/go-openapi/swag" ) // makeOperationTodosFindTodosCmd returns a command to handle operation findTodos @@ -157,7 +156,7 @@ func parseOperationTodosFindTodosResult(resp0 *todos.FindTodosOK, respErr error) var iRespD any = respErr respD, ok := iRespD.(*todos.FindTodosDefault) if ok { - if !swag.IsZero(respD) && !swag.IsZero(respD.Payload) { + if !typeutils.IsZero(respD) && !typeutils.IsZero(respD.Payload) { msgStr, err := json.Marshal(respD.Payload) if err != nil { return "", err @@ -171,7 +170,7 @@ func parseOperationTodosFindTodosResult(resp0 *todos.FindTodosOK, respErr error) eresp0, ok := iResp0.(*todos.FindTodosOK) if ok { // the error response has a payload - if !swag.IsZero(eresp0) && !swag.IsZero(eresp0.Payload) { + if !typeutils.IsZero(eresp0) && !typeutils.IsZero(eresp0.Payload) { msgStr, err := json.Marshal(eresp0.Payload) if err != nil { return "", err @@ -183,7 +182,7 @@ func parseOperationTodosFindTodosResult(resp0 *todos.FindTodosOK, respErr error) } // success responses - if !swag.IsZero(resp0) && !swag.IsZero(resp0.Payload) { + if !typeutils.IsZero(resp0) && !typeutils.IsZero(resp0.Payload) { msgStr, err := json.Marshal(resp0.Payload) if err != nil { return "", err diff --git a/cli/cli/put_test2766_operation.go b/cli/cli/put_test2766_operation.go index 158602c1..662821bd 100644 --- a/cli/cli/put_test2766_operation.go +++ b/cli/cli/put_test2766_operation.go @@ -6,12 +6,11 @@ import ( "encoding/json" "fmt" + "github.com/go-openapi/swag/typeutils" "github.com/go-swagger/examples/cli/client/operations" "github.com/go-swagger/examples/cli/models" "github.com/spf13/cobra" - - "github.com/go-openapi/swag" ) // makeOperationOperationsPutTest2766Cmd returns a command to handle operation putTest2766 @@ -146,7 +145,7 @@ func retrieveOperationOperationsPutTest2766BodyFlag(m *operations.PutTest2766Par m.Body = &flagBodyValue } flagBodyModel := m.Body - if swag.IsZero(flagBodyModel) { + if typeutils.IsZero(flagBodyModel) { flagBodyModel = &models.GithubReactions{} } err, added := retrieveModelGithubReactionsFlags(0, flagBodyModel, "githubReactions", cmd) @@ -179,7 +178,7 @@ func parseOperationOperationsPutTest2766Result(resp0 *operations.PutTest2766OK, eresp0, ok := iResp0.(*operations.PutTest2766OK) if ok { // the error response has a payload - if !swag.IsZero(eresp0) && !swag.IsZero(eresp0.Payload) { + if !typeutils.IsZero(eresp0) && !typeutils.IsZero(eresp0.Payload) { msgStr, err := json.Marshal(eresp0.Payload) if err != nil { return "", err @@ -191,7 +190,7 @@ func parseOperationOperationsPutTest2766Result(resp0 *operations.PutTest2766OK, } // success responses - if !swag.IsZero(resp0) && !swag.IsZero(resp0.Payload) { + if !typeutils.IsZero(resp0) && !typeutils.IsZero(resp0.Payload) { msgStr, err := json.Marshal(resp0.Payload) if err != nil { return "", err diff --git a/cli/cli/update_one_operation.go b/cli/cli/update_one_operation.go index ab84b2b1..bb1afdb6 100644 --- a/cli/cli/update_one_operation.go +++ b/cli/cli/update_one_operation.go @@ -6,12 +6,11 @@ import ( "encoding/json" "fmt" + "github.com/go-openapi/swag/typeutils" "github.com/go-swagger/examples/cli/client/todos" "github.com/go-swagger/examples/cli/models" "github.com/spf13/cobra" - - "github.com/go-openapi/swag" ) // makeOperationTodosUpdateOneCmd returns a command to handle operation updateOne @@ -124,7 +123,7 @@ func retrieveOperationTodosUpdateOneBodyFlag(m *todos.UpdateOneParams, cmdPrefix m.Body = &flagBodyValue } flagBodyModel := m.Body - if swag.IsZero(flagBodyModel) { + if typeutils.IsZero(flagBodyModel) { flagBodyModel = &models.Item{} } err, added := retrieveModelItemFlags(0, flagBodyModel, "item", cmd) @@ -177,7 +176,7 @@ func parseOperationTodosUpdateOneResult(resp0 *todos.UpdateOneOK, respErr error) var iRespD any = respErr respD, ok := iRespD.(*todos.UpdateOneDefault) if ok { - if !swag.IsZero(respD) && !swag.IsZero(respD.Payload) { + if !typeutils.IsZero(respD) && !typeutils.IsZero(respD.Payload) { msgStr, err := json.Marshal(respD.Payload) if err != nil { return "", err @@ -191,7 +190,7 @@ func parseOperationTodosUpdateOneResult(resp0 *todos.UpdateOneOK, respErr error) eresp0, ok := iResp0.(*todos.UpdateOneOK) if ok { // the error response has a payload - if !swag.IsZero(eresp0) && !swag.IsZero(eresp0.Payload) { + if !typeutils.IsZero(eresp0) && !typeutils.IsZero(eresp0.Payload) { msgStr, err := json.Marshal(eresp0.Payload) if err != nil { return "", err @@ -203,7 +202,7 @@ func parseOperationTodosUpdateOneResult(resp0 *todos.UpdateOneOK, respErr error) } // success responses - if !swag.IsZero(resp0) && !swag.IsZero(resp0.Payload) { + if !typeutils.IsZero(resp0) && !typeutils.IsZero(resp0.Payload) { msgStr, err := json.Marshal(resp0.Payload) if err != nil { return "", err diff --git a/cli/client/a_to_do_list_application_client.go b/cli/client/a_to_do_list_application_client.go index bedf8aa6..768a233c 100644 --- a/cli/client/a_to_do_list_application_client.go +++ b/cli/client/a_to_do_list_application_client.go @@ -6,7 +6,6 @@ import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/cli/client/operations" "github.com/go-swagger/examples/cli/client/todos" ) diff --git a/cli/client/operations/put_test2766_parameters.go b/cli/client/operations/put_test2766_parameters.go index 0516efb0..50ae643c 100644 --- a/cli/client/operations/put_test2766_parameters.go +++ b/cli/client/operations/put_test2766_parameters.go @@ -11,8 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - + "github.com/go-openapi/swag/conv" "github.com/go-swagger/examples/cli/models" ) @@ -158,7 +157,7 @@ func (o *PutTest2766Params) WriteToRequest(r runtime.ClientRequest, reg strfmt.R if o.Minus1 != nil { qrMinus1 = *o.Minus1 } - qMinus1 := swag.FormatInt64(qrMinus1) + qMinus1 := conv.FormatInteger(qrMinus1) if qMinus1 != "" { if err := r.SetQueryParam("-1", qMinus1); err != nil { diff --git a/cli/client/operations/put_test2766_responses.go b/cli/client/operations/put_test2766_responses.go index 1699aa9e..803e2fb3 100644 --- a/cli/client/operations/put_test2766_responses.go +++ b/cli/client/operations/put_test2766_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/cli/models" ) diff --git a/cli/client/todos/add_one_parameters.go b/cli/client/todos/add_one_parameters.go index b1159bff..78641ec2 100644 --- a/cli/client/todos/add_one_parameters.go +++ b/cli/client/todos/add_one_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/cli/models" ) diff --git a/cli/client/todos/add_one_responses.go b/cli/client/todos/add_one_responses.go index de2cd0b8..bab3db32 100644 --- a/cli/client/todos/add_one_responses.go +++ b/cli/client/todos/add_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/cli/models" ) diff --git a/cli/client/todos/destroy_one_parameters.go b/cli/client/todos/destroy_one_parameters.go index 0432dac7..2ad290c5 100644 --- a/cli/client/todos/destroy_one_parameters.go +++ b/cli/client/todos/destroy_one_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewDestroyOneParams creates a new DestroyOneParams object, @@ -137,7 +137,7 @@ func (o *DestroyOneParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Re var res []error // path param id - if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { + if err := r.SetPathParam("id", conv.FormatInteger(o.ID)); err != nil { return err } diff --git a/cli/client/todos/destroy_one_responses.go b/cli/client/todos/destroy_one_responses.go index 9664a367..4d4240d0 100644 --- a/cli/client/todos/destroy_one_responses.go +++ b/cli/client/todos/destroy_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/cli/models" ) diff --git a/cli/client/todos/find_todos_parameters.go b/cli/client/todos/find_todos_parameters.go index 11d4559d..3960ac90 100644 --- a/cli/client/todos/find_todos_parameters.go +++ b/cli/client/todos/find_todos_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewFindTodosParams creates a new FindTodosParams object, @@ -172,7 +172,7 @@ func (o *FindTodosParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg if o.Limit != nil { qrLimit = *o.Limit } - qLimit := swag.FormatInt32(qrLimit) + qLimit := conv.FormatInteger(qrLimit) if qLimit != "" { if err := r.SetQueryParam("limit", qLimit); err != nil { @@ -189,7 +189,7 @@ func (o *FindTodosParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg if o.Since != nil { qrSince = *o.Since } - qSince := swag.FormatInt64(qrSince) + qSince := conv.FormatInteger(qrSince) if qSince != "" { if err := r.SetQueryParam("since", qSince); err != nil { diff --git a/cli/client/todos/find_todos_responses.go b/cli/client/todos/find_todos_responses.go index 6bc79103..c87f8caf 100644 --- a/cli/client/todos/find_todos_responses.go +++ b/cli/client/todos/find_todos_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/cli/models" ) diff --git a/cli/client/todos/update_one_parameters.go b/cli/client/todos/update_one_parameters.go index 7c8f4c43..fe650a4f 100644 --- a/cli/client/todos/update_one_parameters.go +++ b/cli/client/todos/update_one_parameters.go @@ -11,8 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - + "github.com/go-openapi/swag/conv" "github.com/go-swagger/examples/cli/models" ) @@ -158,7 +157,7 @@ func (o *UpdateOneParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg } // path param id - if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { + if err := r.SetPathParam("id", conv.FormatInteger(o.ID)); err != nil { return err } diff --git a/cli/client/todos/update_one_responses.go b/cli/client/todos/update_one_responses.go index 9062ddcf..39191f04 100644 --- a/cli/client/todos/update_one_responses.go +++ b/cli/client/todos/update_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/cli/models" ) diff --git a/cli/models/error.go b/cli/models/error.go index 181b96a9..bac28f38 100644 --- a/cli/models/error.go +++ b/cli/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/cli/models/github_reactions.go b/cli/models/github_reactions.go index d43dbeaf..a3826865 100644 --- a/cli/models/github_reactions.go +++ b/cli/models/github_reactions.go @@ -6,7 +6,7 @@ import ( "context" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // GithubReactions github reactions @@ -39,13 +39,13 @@ func (m *GithubReactions) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *GithubReactions) UnmarshalBinary(b []byte) error { var res GithubReactions - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/cli/models/item.go b/cli/models/item.go index 2e517784..2e163a96 100644 --- a/cli/models/item.go +++ b/cli/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/composed-auth/auth/authorizers.go b/composed-auth/auth/authorizers.go index d501e76d..ad3b92c5 100644 --- a/composed-auth/auth/authorizers.go +++ b/composed-auth/auth/authorizers.go @@ -3,6 +3,7 @@ package auth import ( "crypto/rsa" "os" + "slices" jwt "github.com/golang-jwt/jwt/v5" @@ -12,7 +13,7 @@ import ( ) const ( - // currently unused: privateKeyPath = "keys/apiKey.prv" + // currently unused: privateKeyPath = "keys/apiKey.prv". publicKeyPath = "keys/apiKey.pem" issuerName = "example.com" ) @@ -20,15 +21,16 @@ const ( var ( userDb map[string]string - // Keys used to sign and verify our tokens + // Keys used to sign and verify our tokens. verifyKey *rsa.PublicKey - // currently unused: signKey *rsa.PrivateKey + // currently unused: signKey *rsa.PrivateKey. ) -// roleClaims describes the format of our JWT token's claims +// roleClaims describes the format of our JWT token's claims. type roleClaims struct { - Roles []string `json:"roles"` jwt.MapClaims + + Roles []string `json:"roles"` } func init() { @@ -52,7 +54,7 @@ func init() { // Customized authorizer methods for our sample API // IsRegistered determines if the user is properly registered, -// i.e if a valid username:password pair has been provided +// i.e if a valid username:password pair has been provided. func IsRegistered(user, pass string) (*models.Principal, error) { password, ok := userDb[user] if !ok || pass != password { @@ -64,7 +66,7 @@ func IsRegistered(user, pass string) (*models.Principal, error) { }, nil } -// IsReseller tells if the API key is a JWT signed by us with a claim to be a reseller +// IsReseller tells if the API key is a JWT signed by us with a claim to be a reseller. func IsReseller(token string) (*models.Principal, error) { claims, err := parseAndCheckToken(token) if err != nil { @@ -85,13 +87,7 @@ func IsReseller(token string) (*models.Principal, error) { return nil, errors.New(403, "Forbidden: insufficient API key privileges") } - isReseller := false - for _, role := range claims.Roles { - if role == "reseller" { - isReseller = true - break - } - } + isReseller := slices.Contains(claims.Roles, "reseller") if !isReseller { return nil, errors.New(403, "Forbidden: insufficient API key privileges") @@ -104,7 +100,7 @@ func IsReseller(token string) (*models.Principal, error) { // HasRole tells if the Bearer token is a JWT signed by us with a claim to be // member of an authorization scope. -// We verify that the claimed role is one of the passed scopes +// We verify that the claimed role is one of the passed scopes. func HasRole(token string, scopes []string) (*models.Principal, error) { claims, err := parseAndCheckToken(token) if err != nil { diff --git a/composed-auth/models/error.go b/composed-auth/models/error.go index d780948b..3403d63e 100644 --- a/composed-auth/models/error.go +++ b/composed-auth/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/composed-auth/models/order.go b/composed-auth/models/order.go index 2d89f201..7d830b9a 100644 --- a/composed-auth/models/order.go +++ b/composed-auth/models/order.go @@ -9,7 +9,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) @@ -54,12 +55,12 @@ func (m *Order) validateOrderID(formats strfmt.Registry) error { } func (m *Order) validateOrderLines(formats strfmt.Registry) error { - if swag.IsZero(m.OrderLines) { // not required + if typeutils.IsZero(m.OrderLines) { // not required return nil } for i := 0; i < len(m.OrderLines); i++ { - if swag.IsZero(m.OrderLines[i]) { // not required + if typeutils.IsZero(m.OrderLines[i]) { // not required continue } @@ -103,7 +104,7 @@ func (m *Order) contextValidateOrderLines(ctx context.Context, formats strfmt.Re if m.OrderLines[i] != nil { - if swag.IsZero(m.OrderLines[i]) { // not required + if typeutils.IsZero(m.OrderLines[i]) { // not required return nil } @@ -131,13 +132,13 @@ func (m *Order) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Order) UnmarshalBinary(b []byte) error { var res Order - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res @@ -254,13 +255,13 @@ func (m *OrderLine) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *OrderLine) UnmarshalBinary(b []byte) error { var res OrderLine - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/composed-auth/models/principal.go b/composed-auth/models/principal.go index 32b2f8bb..16f04e90 100644 --- a/composed-auth/models/principal.go +++ b/composed-auth/models/principal.go @@ -6,7 +6,7 @@ import ( "context" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // Principal principal @@ -36,13 +36,13 @@ func (m *Principal) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Principal) UnmarshalBinary(b []byte) error { var res Principal - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/composed-auth/restapi/configure_multi_auth_example.go b/composed-auth/restapi/configure_multi_auth_example.go index 7b263a90..44af7c53 100644 --- a/composed-auth/restapi/configure_multi_auth_example.go +++ b/composed-auth/restapi/configure_multi_auth_example.go @@ -7,22 +7,20 @@ import ( "log" "net/http" - "github.com/davecgh/go-spew/spew" - errors "github.com/go-openapi/errors" runtime "github.com/go-openapi/runtime" middleware "github.com/go-openapi/runtime/middleware" - - "github.com/go-swagger/examples/composed-auth/restapi/operations" + "github.com/go-openapi/testify/v2/tools/spew" auth "github.com/go-swagger/examples/composed-auth/auth" models "github.com/go-swagger/examples/composed-auth/models" + "github.com/go-swagger/examples/composed-auth/restapi/operations" ) //go:generate swagger generate server --target .. --name multi-auth-example --spec ../swagger.yml --principal models.Principal func configureFlags(api *operations.MultiAuthExampleAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/composed-auth/restapi/operations/add_order_responses.go b/composed-auth/restapi/operations/add_order_responses.go index f6dfc01c..28c19e6c 100644 --- a/composed-auth/restapi/operations/add_order_responses.go +++ b/composed-auth/restapi/operations/add_order_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/composed-auth/models" ) diff --git a/composed-auth/restapi/operations/get_account_responses.go b/composed-auth/restapi/operations/get_account_responses.go index 45e1ee6a..466af89f 100644 --- a/composed-auth/restapi/operations/get_account_responses.go +++ b/composed-auth/restapi/operations/get_account_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/composed-auth/models" ) diff --git a/composed-auth/restapi/operations/get_items_responses.go b/composed-auth/restapi/operations/get_items_responses.go index 81be5df2..6eab36f2 100644 --- a/composed-auth/restapi/operations/get_items_responses.go +++ b/composed-auth/restapi/operations/get_items_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/composed-auth/models" ) diff --git a/composed-auth/restapi/operations/get_order_responses.go b/composed-auth/restapi/operations/get_order_responses.go index eec26646..bd0ee1f4 100644 --- a/composed-auth/restapi/operations/get_order_responses.go +++ b/composed-auth/restapi/operations/get_order_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/composed-auth/models" ) diff --git a/composed-auth/restapi/operations/get_orders_for_item_responses.go b/composed-auth/restapi/operations/get_orders_for_item_responses.go index 1aa7c434..1f77bf15 100644 --- a/composed-auth/restapi/operations/get_orders_for_item_responses.go +++ b/composed-auth/restapi/operations/get_orders_for_item_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/composed-auth/models" ) diff --git a/composed-auth/restapi/operations/multi_auth_example_api.go b/composed-auth/restapi/operations/multi_auth_example_api.go index 43789340..6b7098c4 100644 --- a/composed-auth/restapi/operations/multi_auth_example_api.go +++ b/composed-auth/restapi/operations/multi_auth_example_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/composed-auth/models" ) @@ -208,7 +208,7 @@ type MultiAuthExampleAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/composed-auth/restapi/server.go b/composed-auth/restapi/server.go index fad14079..2006bc40 100644 --- a/composed-auth/restapi/server.go +++ b/composed-auth/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/composed-auth/restapi/operations" ) @@ -368,7 +368,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -383,7 +383,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/contributed-templates/stratoscale/client/pet/pet_client.go b/contributed-templates/stratoscale/client/pet/pet_client.go index 32542c48..0b04ef9f 100644 --- a/contributed-templates/stratoscale/client/pet/pet_client.go +++ b/contributed-templates/stratoscale/client/pet/pet_client.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/go-openapi/runtime" - strfmt "github.com/go-openapi/strfmt" ) diff --git a/contributed-templates/stratoscale/client/pet/pet_create_parameters.go b/contributed-templates/stratoscale/client/pet/pet_create_parameters.go index ba304d1e..39eb0b25 100644 --- a/contributed-templates/stratoscale/client/pet/pet_create_parameters.go +++ b/contributed-templates/stratoscale/client/pet/pet_create_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/client/pet/pet_create_responses.go b/contributed-templates/stratoscale/client/pet/pet_create_responses.go index 9f2aa7b5..909cb269 100644 --- a/contributed-templates/stratoscale/client/pet/pet_create_responses.go +++ b/contributed-templates/stratoscale/client/pet/pet_create_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/client/pet/pet_delete_parameters.go b/contributed-templates/stratoscale/client/pet/pet_delete_parameters.go index 8896bd48..f4540d60 100644 --- a/contributed-templates/stratoscale/client/pet/pet_delete_parameters.go +++ b/contributed-templates/stratoscale/client/pet/pet_delete_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewPetDeleteParams creates a new PetDeleteParams object, @@ -162,7 +162,7 @@ func (o *PetDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg } // path param petId - if err := r.SetPathParam("petId", swag.FormatInt64(o.PetID)); err != nil { + if err := r.SetPathParam("petId", conv.FormatInteger(o.PetID)); err != nil { return err } diff --git a/contributed-templates/stratoscale/client/pet/pet_get_parameters.go b/contributed-templates/stratoscale/client/pet/pet_get_parameters.go index 44d41edd..86a253a2 100644 --- a/contributed-templates/stratoscale/client/pet/pet_get_parameters.go +++ b/contributed-templates/stratoscale/client/pet/pet_get_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewPetGetParams creates a new PetGetParams object, @@ -140,7 +140,7 @@ func (o *PetGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regist var res []error // path param petId - if err := r.SetPathParam("petId", swag.FormatInt64(o.PetID)); err != nil { + if err := r.SetPathParam("petId", conv.FormatInteger(o.PetID)); err != nil { return err } diff --git a/contributed-templates/stratoscale/client/pet/pet_get_responses.go b/contributed-templates/stratoscale/client/pet/pet_get_responses.go index 7d648e76..588488c0 100644 --- a/contributed-templates/stratoscale/client/pet/pet_get_responses.go +++ b/contributed-templates/stratoscale/client/pet/pet_get_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/client/pet/pet_list_parameters.go b/contributed-templates/stratoscale/client/pet/pet_list_parameters.go index 717f80a9..57c9358d 100644 --- a/contributed-templates/stratoscale/client/pet/pet_list_parameters.go +++ b/contributed-templates/stratoscale/client/pet/pet_list_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/stringutils" ) // NewPetListParams creates a new PetListParams object, @@ -166,7 +166,7 @@ func (o *PetListParams) bindParamStatus(formats strfmt.Registry) []string { } // items.CollectionFormat: "multi" - statusIS := swag.JoinByFormat(statusIC, "multi") + statusIS := stringutils.JoinByFormat(statusIC, "multi") return statusIS } diff --git a/contributed-templates/stratoscale/client/pet/pet_list_responses.go b/contributed-templates/stratoscale/client/pet/pet_list_responses.go index 0d889feb..b5d95ed0 100644 --- a/contributed-templates/stratoscale/client/pet/pet_list_responses.go +++ b/contributed-templates/stratoscale/client/pet/pet_list_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/client/pet/pet_update_parameters.go b/contributed-templates/stratoscale/client/pet/pet_update_parameters.go index de3eb287..844113eb 100644 --- a/contributed-templates/stratoscale/client/pet/pet_update_parameters.go +++ b/contributed-templates/stratoscale/client/pet/pet_update_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/client/pet/pet_update_responses.go b/contributed-templates/stratoscale/client/pet/pet_update_responses.go index 575c9886..d997e1fa 100644 --- a/contributed-templates/stratoscale/client/pet/pet_update_responses.go +++ b/contributed-templates/stratoscale/client/pet/pet_update_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/client/pet/pet_upload_image_parameters.go b/contributed-templates/stratoscale/client/pet/pet_upload_image_parameters.go index 71d8d4ac..9ed00542 100644 --- a/contributed-templates/stratoscale/client/pet/pet_upload_image_parameters.go +++ b/contributed-templates/stratoscale/client/pet/pet_upload_image_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewPetUploadImageParams creates a new PetUploadImageParams object, @@ -199,7 +199,7 @@ func (o *PetUploadImageParams) WriteToRequest(r runtime.ClientRequest, reg strfm } // path param petId - if err := r.SetPathParam("petId", swag.FormatInt64(o.PetID)); err != nil { + if err := r.SetPathParam("petId", conv.FormatInteger(o.PetID)); err != nil { return err } diff --git a/contributed-templates/stratoscale/client/pet/pet_upload_image_responses.go b/contributed-templates/stratoscale/client/pet/pet_upload_image_responses.go index 0b84a4a7..5f368253 100644 --- a/contributed-templates/stratoscale/client/pet/pet_upload_image_responses.go +++ b/contributed-templates/stratoscale/client/pet/pet_upload_image_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/client/petstore_client.go b/contributed-templates/stratoscale/client/petstore_client.go index 6a724256..86a60dcb 100644 --- a/contributed-templates/stratoscale/client/petstore_client.go +++ b/contributed-templates/stratoscale/client/petstore_client.go @@ -9,7 +9,6 @@ import ( "github.com/go-openapi/runtime" rtclient "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/contributed-templates/stratoscale/client/pet" "github.com/go-swagger/examples/contributed-templates/stratoscale/client/store" ) diff --git a/contributed-templates/stratoscale/client/store/order_create_parameters.go b/contributed-templates/stratoscale/client/store/order_create_parameters.go index 055f3e82..161e3bb0 100644 --- a/contributed-templates/stratoscale/client/store/order_create_parameters.go +++ b/contributed-templates/stratoscale/client/store/order_create_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/client/store/order_create_responses.go b/contributed-templates/stratoscale/client/store/order_create_responses.go index f89100b5..15376138 100644 --- a/contributed-templates/stratoscale/client/store/order_create_responses.go +++ b/contributed-templates/stratoscale/client/store/order_create_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/client/store/order_delete_parameters.go b/contributed-templates/stratoscale/client/store/order_delete_parameters.go index 551a5283..87d3fee3 100644 --- a/contributed-templates/stratoscale/client/store/order_delete_parameters.go +++ b/contributed-templates/stratoscale/client/store/order_delete_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewOrderDeleteParams creates a new OrderDeleteParams object, @@ -140,7 +140,7 @@ func (o *OrderDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.R var res []error // path param orderId - if err := r.SetPathParam("orderId", swag.FormatInt64(o.OrderID)); err != nil { + if err := r.SetPathParam("orderId", conv.FormatInteger(o.OrderID)); err != nil { return err } diff --git a/contributed-templates/stratoscale/client/store/order_get_parameters.go b/contributed-templates/stratoscale/client/store/order_get_parameters.go index 0283da81..0fa3fef0 100644 --- a/contributed-templates/stratoscale/client/store/order_get_parameters.go +++ b/contributed-templates/stratoscale/client/store/order_get_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewOrderGetParams creates a new OrderGetParams object, @@ -140,7 +140,7 @@ func (o *OrderGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regi var res []error // path param orderId - if err := r.SetPathParam("orderId", swag.FormatInt64(o.OrderID)); err != nil { + if err := r.SetPathParam("orderId", conv.FormatInteger(o.OrderID)); err != nil { return err } diff --git a/contributed-templates/stratoscale/client/store/order_get_responses.go b/contributed-templates/stratoscale/client/store/order_get_responses.go index 3b3a3389..4a29bfed 100644 --- a/contributed-templates/stratoscale/client/store/order_get_responses.go +++ b/contributed-templates/stratoscale/client/store/order_get_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/client/store/store_client.go b/contributed-templates/stratoscale/client/store/store_client.go index 1af27e7a..9dea4988 100644 --- a/contributed-templates/stratoscale/client/store/store_client.go +++ b/contributed-templates/stratoscale/client/store/store_client.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/go-openapi/runtime" - strfmt "github.com/go-openapi/strfmt" ) diff --git a/contributed-templates/stratoscale/models/api_response.go b/contributed-templates/stratoscale/models/api_response.go index c93c444a..8861534d 100644 --- a/contributed-templates/stratoscale/models/api_response.go +++ b/contributed-templates/stratoscale/models/api_response.go @@ -6,7 +6,7 @@ import ( "context" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // APIResponse is the response to an API call @@ -39,13 +39,13 @@ func (m *APIResponse) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *APIResponse) UnmarshalBinary(b []byte) error { var res APIResponse - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/contributed-templates/stratoscale/models/category.go b/contributed-templates/stratoscale/models/category.go index 6a479df4..d7e2973b 100644 --- a/contributed-templates/stratoscale/models/category.go +++ b/contributed-templates/stratoscale/models/category.go @@ -6,7 +6,7 @@ import ( "context" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // Category category @@ -36,13 +36,13 @@ func (m *Category) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Category) UnmarshalBinary(b []byte) error { var res Category - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/contributed-templates/stratoscale/models/order.go b/contributed-templates/stratoscale/models/order.go index 3f29bcbe..aa71c04e 100644 --- a/contributed-templates/stratoscale/models/order.go +++ b/contributed-templates/stratoscale/models/order.go @@ -8,7 +8,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) @@ -57,7 +58,7 @@ func (m *Order) Validate(formats strfmt.Registry) error { } func (m *Order) validateShipDate(formats strfmt.Registry) error { - if swag.IsZero(m.ShipDate) { // not required + if typeutils.IsZero(m.ShipDate) { // not required return nil } @@ -101,7 +102,7 @@ func (m *Order) validateStatusEnum(path, location string, value string) error { } func (m *Order) validateStatus(formats strfmt.Registry) error { - if swag.IsZero(m.Status) { // not required + if typeutils.IsZero(m.Status) { // not required return nil } @@ -123,13 +124,13 @@ func (m *Order) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Order) UnmarshalBinary(b []byte) error { var res Order - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/contributed-templates/stratoscale/models/pet.go b/contributed-templates/stratoscale/models/pet.go index 4b2c9e20..d71a9646 100644 --- a/contributed-templates/stratoscale/models/pet.go +++ b/contributed-templates/stratoscale/models/pet.go @@ -10,7 +10,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) @@ -73,7 +74,7 @@ func (m *Pet) Validate(formats strfmt.Registry) error { } func (m *Pet) validateCategory(formats strfmt.Registry) error { - if swag.IsZero(m.Category) { // not required + if typeutils.IsZero(m.Category) { // not required return nil } @@ -146,7 +147,7 @@ func (m *Pet) validateStatusEnum(path, location string, value string) error { } func (m *Pet) validateStatus(formats strfmt.Registry) error { - if swag.IsZero(m.Status) { // not required + if typeutils.IsZero(m.Status) { // not required return nil } @@ -159,12 +160,12 @@ func (m *Pet) validateStatus(formats strfmt.Registry) error { } func (m *Pet) validateTags(formats strfmt.Registry) error { - if swag.IsZero(m.Tags) { // not required + if typeutils.IsZero(m.Tags) { // not required return nil } for i := 0; i < len(m.Tags); i++ { - if swag.IsZero(m.Tags[i]) { // not required + if typeutils.IsZero(m.Tags[i]) { // not required continue } @@ -210,7 +211,7 @@ func (m *Pet) contextValidateCategory(ctx context.Context, formats strfmt.Regist if m.Category != nil { - if swag.IsZero(m.Category) { // not required + if typeutils.IsZero(m.Category) { // not required return nil } @@ -237,7 +238,7 @@ func (m *Pet) contextValidateTags(ctx context.Context, formats strfmt.Registry) if m.Tags[i] != nil { - if swag.IsZero(m.Tags[i]) { // not required + if typeutils.IsZero(m.Tags[i]) { // not required return nil } @@ -265,13 +266,13 @@ func (m *Pet) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Pet) UnmarshalBinary(b []byte) error { var res Pet - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/contributed-templates/stratoscale/models/tag.go b/contributed-templates/stratoscale/models/tag.go index cde149f0..e4ccda03 100644 --- a/contributed-templates/stratoscale/models/tag.go +++ b/contributed-templates/stratoscale/models/tag.go @@ -6,7 +6,7 @@ import ( "context" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // Tag tag @@ -36,13 +36,13 @@ func (m *Tag) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Tag) UnmarshalBinary(b []byte) error { var res Tag - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/contributed-templates/stratoscale/restapi/operations/pet/pet_create_responses.go b/contributed-templates/stratoscale/restapi/operations/pet/pet_create_responses.go index c8283b37..1c330c80 100644 --- a/contributed-templates/stratoscale/restapi/operations/pet/pet_create_responses.go +++ b/contributed-templates/stratoscale/restapi/operations/pet/pet_create_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_parameters.go b/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_parameters.go index c71bfd44..5e084db9 100644 --- a/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_parameters.go +++ b/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_parameters.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewPetDeleteParams creates a new PetDeleteParams object @@ -89,7 +89,7 @@ func (o *PetDeleteParams) bindPetID(rawData []string, hasKey bool, formats strfm // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("petId", "path", "int64", raw) } diff --git a/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_urlbuilder.go b/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_urlbuilder.go index 0a29ea06..e56b2fd3 100644 --- a/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_urlbuilder.go +++ b/contributed-templates/stratoscale/restapi/operations/pet/pet_delete_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // PetDeleteURL generates an URL for the pet delete operation @@ -41,7 +41,7 @@ func (o *PetDeleteURL) Build() (*url.URL, error) { var _path = "/pet/{petId}" - petID := swag.FormatInt64(o.PetID) + petID := conv.FormatInteger(o.PetID) if petID != "" { _path = strings.ReplaceAll(_path, "{petId}", petID) } else { diff --git a/contributed-templates/stratoscale/restapi/operations/pet/pet_get_parameters.go b/contributed-templates/stratoscale/restapi/operations/pet/pet_get_parameters.go index 274f4595..26a9d8a9 100644 --- a/contributed-templates/stratoscale/restapi/operations/pet/pet_get_parameters.go +++ b/contributed-templates/stratoscale/restapi/operations/pet/pet_get_parameters.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewPetGetParams creates a new PetGetParams object @@ -63,7 +63,7 @@ func (o *PetGetParams) bindPetID(rawData []string, hasKey bool, formats strfmt.R // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("petId", "path", "int64", raw) } diff --git a/contributed-templates/stratoscale/restapi/operations/pet/pet_get_responses.go b/contributed-templates/stratoscale/restapi/operations/pet/pet_get_responses.go index 5e3aca4c..0520c684 100644 --- a/contributed-templates/stratoscale/restapi/operations/pet/pet_get_responses.go +++ b/contributed-templates/stratoscale/restapi/operations/pet/pet_get_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/restapi/operations/pet/pet_get_urlbuilder.go b/contributed-templates/stratoscale/restapi/operations/pet/pet_get_urlbuilder.go index 255feaa3..0be26c3f 100644 --- a/contributed-templates/stratoscale/restapi/operations/pet/pet_get_urlbuilder.go +++ b/contributed-templates/stratoscale/restapi/operations/pet/pet_get_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // PetGetURL generates an URL for the pet get operation @@ -41,7 +41,7 @@ func (o *PetGetURL) Build() (*url.URL, error) { var _path = "/pet/{petId}" - petID := swag.FormatInt64(o.PetID) + petID := conv.FormatInteger(o.PetID) if petID != "" { _path = strings.ReplaceAll(_path, "{petId}", petID) } else { diff --git a/contributed-templates/stratoscale/restapi/operations/pet/pet_list_responses.go b/contributed-templates/stratoscale/restapi/operations/pet/pet_list_responses.go index 56020ae5..146f66af 100644 --- a/contributed-templates/stratoscale/restapi/operations/pet/pet_list_responses.go +++ b/contributed-templates/stratoscale/restapi/operations/pet/pet_list_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/restapi/operations/pet/pet_list_urlbuilder.go b/contributed-templates/stratoscale/restapi/operations/pet/pet_list_urlbuilder.go index 989e322c..1910e067 100644 --- a/contributed-templates/stratoscale/restapi/operations/pet/pet_list_urlbuilder.go +++ b/contributed-templates/stratoscale/restapi/operations/pet/pet_list_urlbuilder.go @@ -7,7 +7,7 @@ import ( "net/url" golangswaggerpaths "path" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/stringutils" ) // PetListURL generates an URL for the pet list operation @@ -56,7 +56,7 @@ func (o *PetListURL) Build() (*url.URL, error) { } } - status := swag.JoinByFormat(statusIR, "multi") + status := stringutils.JoinByFormat(statusIR, "multi") for _, qsv := range status { qs.Add("status", qsv) diff --git a/contributed-templates/stratoscale/restapi/operations/pet/pet_update_responses.go b/contributed-templates/stratoscale/restapi/operations/pet/pet_update_responses.go index 2c41e123..36ec2b6d 100644 --- a/contributed-templates/stratoscale/restapi/operations/pet/pet_update_responses.go +++ b/contributed-templates/stratoscale/restapi/operations/pet/pet_update_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/restapi/operations/pet/pet_upload_image_parameters.go b/contributed-templates/stratoscale/restapi/operations/pet/pet_upload_image_parameters.go index 2e30c609..90ca1439 100644 --- a/contributed-templates/stratoscale/restapi/operations/pet/pet_upload_image_parameters.go +++ b/contributed-templates/stratoscale/restapi/operations/pet/pet_upload_image_parameters.go @@ -12,7 +12,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // PetUploadImageMaxParseMemory sets the maximum size in bytes for @@ -136,7 +136,7 @@ func (o *PetUploadImageParams) bindPetID(rawData []string, hasKey bool, formats // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("petId", "path", "int64", raw) } diff --git a/contributed-templates/stratoscale/restapi/operations/pet/pet_upload_image_responses.go b/contributed-templates/stratoscale/restapi/operations/pet/pet_upload_image_responses.go index d2a409ec..5b977216 100644 --- a/contributed-templates/stratoscale/restapi/operations/pet/pet_upload_image_responses.go +++ b/contributed-templates/stratoscale/restapi/operations/pet/pet_upload_image_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/restapi/operations/pet/pet_upload_image_urlbuilder.go b/contributed-templates/stratoscale/restapi/operations/pet/pet_upload_image_urlbuilder.go index 4021503c..41499c4b 100644 --- a/contributed-templates/stratoscale/restapi/operations/pet/pet_upload_image_urlbuilder.go +++ b/contributed-templates/stratoscale/restapi/operations/pet/pet_upload_image_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // PetUploadImageURL generates an URL for the pet upload image operation @@ -41,7 +41,7 @@ func (o *PetUploadImageURL) Build() (*url.URL, error) { var _path = "/pet/{petId}/image" - petID := swag.FormatInt64(o.PetID) + petID := conv.FormatInteger(o.PetID) if petID != "" { _path = strings.ReplaceAll(_path, "{petId}", petID) } else { diff --git a/contributed-templates/stratoscale/restapi/operations/petstore_api.go b/contributed-templates/stratoscale/restapi/operations/petstore_api.go index af969e3c..a431c675 100644 --- a/contributed-templates/stratoscale/restapi/operations/petstore_api.go +++ b/contributed-templates/stratoscale/restapi/operations/petstore_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/contributed-templates/stratoscale/restapi/operations/pet" "github.com/go-swagger/examples/contributed-templates/stratoscale/restapi/operations/store" @@ -197,7 +197,7 @@ type PetstoreAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/contributed-templates/stratoscale/restapi/operations/store/order_create_responses.go b/contributed-templates/stratoscale/restapi/operations/store/order_create_responses.go index 9301657c..d5fe23ad 100644 --- a/contributed-templates/stratoscale/restapi/operations/store/order_create_responses.go +++ b/contributed-templates/stratoscale/restapi/operations/store/order_create_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/restapi/operations/store/order_delete_parameters.go b/contributed-templates/stratoscale/restapi/operations/store/order_delete_parameters.go index 8fc90703..9272d41b 100644 --- a/contributed-templates/stratoscale/restapi/operations/store/order_delete_parameters.go +++ b/contributed-templates/stratoscale/restapi/operations/store/order_delete_parameters.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -65,7 +65,7 @@ func (o *OrderDeleteParams) bindOrderID(rawData []string, hasKey bool, formats s // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("orderId", "path", "int64", raw) } diff --git a/contributed-templates/stratoscale/restapi/operations/store/order_delete_urlbuilder.go b/contributed-templates/stratoscale/restapi/operations/store/order_delete_urlbuilder.go index 2b51ebf3..252168f2 100644 --- a/contributed-templates/stratoscale/restapi/operations/store/order_delete_urlbuilder.go +++ b/contributed-templates/stratoscale/restapi/operations/store/order_delete_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // OrderDeleteURL generates an URL for the order delete operation @@ -41,7 +41,7 @@ func (o *OrderDeleteURL) Build() (*url.URL, error) { var _path = "/store/order/{orderId}" - orderID := swag.FormatInt64(o.OrderID) + orderID := conv.FormatInteger(o.OrderID) if orderID != "" { _path = strings.ReplaceAll(_path, "{orderId}", orderID) } else { diff --git a/contributed-templates/stratoscale/restapi/operations/store/order_get_parameters.go b/contributed-templates/stratoscale/restapi/operations/store/order_get_parameters.go index 99594763..8bf19a6f 100644 --- a/contributed-templates/stratoscale/restapi/operations/store/order_get_parameters.go +++ b/contributed-templates/stratoscale/restapi/operations/store/order_get_parameters.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -66,7 +66,7 @@ func (o *OrderGetParams) bindOrderID(rawData []string, hasKey bool, formats strf // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("orderId", "path", "int64", raw) } diff --git a/contributed-templates/stratoscale/restapi/operations/store/order_get_responses.go b/contributed-templates/stratoscale/restapi/operations/store/order_get_responses.go index e8178cf9..427860c7 100644 --- a/contributed-templates/stratoscale/restapi/operations/store/order_get_responses.go +++ b/contributed-templates/stratoscale/restapi/operations/store/order_get_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/contributed-templates/stratoscale/models" ) diff --git a/contributed-templates/stratoscale/restapi/operations/store/order_get_urlbuilder.go b/contributed-templates/stratoscale/restapi/operations/store/order_get_urlbuilder.go index b6512f7e..e5ba1964 100644 --- a/contributed-templates/stratoscale/restapi/operations/store/order_get_urlbuilder.go +++ b/contributed-templates/stratoscale/restapi/operations/store/order_get_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // OrderGetURL generates an URL for the order get operation @@ -41,7 +41,7 @@ func (o *OrderGetURL) Build() (*url.URL, error) { var _path = "/store/order/{orderId}" - orderID := swag.FormatInt64(o.OrderID) + orderID := conv.FormatInteger(o.OrderID) if orderID != "" { _path = strings.ReplaceAll(_path, "{orderId}", orderID) } else { diff --git a/external-types/fred/my_type.go b/external-types/fred/my_type.go index 59f6d04a..22551c02 100644 --- a/external-types/fred/my_type.go +++ b/external-types/fred/my_type.go @@ -10,28 +10,28 @@ import ( // MyAlternateType ... type MyAlternateType string -// Validate MyAlternateType +// Validate MyAlternateType. func (MyAlternateType) Validate(strfmt.Registry) error { return nil } func (MyAlternateType) ContextValidate(context.Context, strfmt.Registry) error { return nil } // MyAlternateInteger ... type MyAlternateInteger int -// Validate MyAlternateInteger +// Validate MyAlternateInteger. func (MyAlternateInteger) Validate(strfmt.Registry) error { return nil } func (MyAlternateInteger) ContextValidate(context.Context, strfmt.Registry) error { return nil } // MyAlternateString ... type MyAlternateString string -// Validate MyAlternateString +// Validate MyAlternateString. func (MyAlternateString) Validate(strfmt.Registry) error { return nil } func (MyAlternateString) ContextValidate(context.Context, strfmt.Registry) error { return nil } // MyAlternateOtherType ... type MyAlternateOtherType struct{} -// Validate MyAlternateOtherType +// Validate MyAlternateOtherType. func (MyAlternateOtherType) Validate(strfmt.Registry) error { return nil } func (MyAlternateOtherType) ContextValidate(context.Context, strfmt.Registry) error { return nil } diff --git a/external-types/models/my_custom_array_nullable.go b/external-types/models/my_custom_array_nullable.go index 5ece41b3..2a27d3c9 100644 --- a/external-types/models/my_custom_array_nullable.go +++ b/external-types/models/my_custom_array_nullable.go @@ -9,7 +9,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/typeutils" alternate "github.com/go-swagger/examples/external-types/fred" ) @@ -26,7 +26,7 @@ func (m MyCustomArrayNullable) Validate(formats strfmt.Registry) error { var res []error for i := 0; i < len(m); i++ { - if swag.IsZero(m[i]) { // not required + if typeutils.IsZero(m[i]) { // not required continue } diff --git a/external-types/models/my_custom_map_nullable.go b/external-types/models/my_custom_map_nullable.go index e2ed8baa..c53cae5a 100644 --- a/external-types/models/my_custom_map_nullable.go +++ b/external-types/models/my_custom_map_nullable.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/typeutils" alternate "github.com/go-swagger/examples/external-types/fred" ) @@ -28,7 +28,7 @@ func (m MyCustomMapNullable) Validate(formats strfmt.Registry) error { for kk := range m[k] { - if swag.IsZero(m[k][kk]) { // not required + if typeutils.IsZero(m[k][kk]) { // not required continue } if val, ok := m[k][kk]; ok { diff --git a/external-types/models/my_ext_collection.go b/external-types/models/my_ext_collection.go index 5f196b4f..39a0fdff 100644 --- a/external-types/models/my_ext_collection.go +++ b/external-types/models/my_ext_collection.go @@ -9,7 +9,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/typeutils" go_ext "github.com/go-swagger/examples/external-types/go-ext" ) @@ -51,7 +51,7 @@ func (m MyExtCollection) ContextValidate(ctx context.Context, formats strfmt.Reg for i := 0; i < len(m); i++ { - if swag.IsZero(m[i]) { // not required + if typeutils.IsZero(m[i]) { // not required return nil } diff --git a/external-types/models/my_interface_object.go b/external-types/models/my_interface_object.go index 17db63f5..f6437549 100644 --- a/external-types/models/my_interface_object.go +++ b/external-types/models/my_interface_object.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" "github.com/go-swagger/examples/external-types/fred" ) @@ -92,13 +92,13 @@ func (m *MyInterfaceObject) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *MyInterfaceObject) UnmarshalBinary(b []byte) error { var res MyInterfaceObject - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/external-types/models/my_reader_object.go b/external-types/models/my_reader_object.go index 4c6ca18d..edf06866 100644 --- a/external-types/models/my_reader_object.go +++ b/external-types/models/my_reader_object.go @@ -6,7 +6,7 @@ import ( "context" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-swagger/examples/external-types/fred" alternate "github.com/go-swagger/examples/external-types/fred" ) @@ -54,13 +54,13 @@ func (m *MyReaderObject) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *MyReaderObject) UnmarshalBinary(b []byte) error { var res MyReaderObject - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/external-types/models/my_tuple.go b/external-types/models/my_tuple.go index fcd9cc30..a3ff2835 100644 --- a/external-types/models/my_tuple.go +++ b/external-types/models/my_tuple.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" "github.com/go-swagger/examples/external-types/fred" ) @@ -251,13 +251,13 @@ func (m *MyTuple) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *MyTuple) UnmarshalBinary(b []byte) error { var res MyTuple - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/external-types/models/my_type.go b/external-types/models/my_type.go index 17ae1f97..6332caca 100644 --- a/external-types/models/my_type.go +++ b/external-types/models/my_type.go @@ -7,40 +7,40 @@ import ( "github.com/go-openapi/strfmt" ) -// MyType is a type manually added to the models package (NOT GENERATED) +// MyType is a type manually added to the models package (NOT GENERATED). type MyType string -// Validate MyType +// Validate MyType. func (MyType) Validate(strfmt.Registry) error { return nil } -// ContextValidate MyType +// ContextValidate MyType. func (MyType) ContextValidate(context.Context, strfmt.Registry) error { return nil } // MyInteger ... type MyInteger int -// Validate MyInteger +// Validate MyInteger. func (MyInteger) Validate(strfmt.Registry) error { return nil } -// ContextValidate MyInteger +// ContextValidate MyInteger. func (MyInteger) ContextValidate(context.Context, strfmt.Registry) error { return nil } // MyString ... type MyString string -// Validate MyString +// Validate MyString. func (MyString) Validate(strfmt.Registry) error { return nil } -// ContextValidate MyInteger +// ContextValidate MyInteger. func (MyString) ContextValidate(context.Context, strfmt.Registry) error { return nil } // MyOtherType ... type MyOtherType struct{} -// Validate MyOtherType +// Validate MyOtherType. func (MyOtherType) Validate(strfmt.Registry) error { return nil } -// ContextValidate MyOtherType +// ContextValidate MyOtherType. func (MyOtherType) ContextValidate(context.Context, strfmt.Registry) error { return nil } // MyStreamer ... diff --git a/external-types/models/object_with_no_validate.go b/external-types/models/object_with_no_validate.go index 56cd4226..8f58243a 100644 --- a/external-types/models/object_with_no_validate.go +++ b/external-types/models/object_with_no_validate.go @@ -8,7 +8,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) @@ -55,7 +56,7 @@ func (m *ObjectWithNoValidate) validateMyMandatoryRequest(formats strfmt.Registr } func (m *ObjectWithNoValidate) validateMyRequest(formats strfmt.Registry) error { - if swag.IsZero(m.MyRequest) { // not required + if typeutils.IsZero(m.MyRequest) { // not required return nil } @@ -72,13 +73,13 @@ func (m *ObjectWithNoValidate) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *ObjectWithNoValidate) UnmarshalBinary(b []byte) error { var res ObjectWithNoValidate - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/external-types/models/tuple_with_no_validate.go b/external-types/models/tuple_with_no_validate.go index b472588b..7d9dd898 100644 --- a/external-types/models/tuple_with_no_validate.go +++ b/external-types/models/tuple_with_no_validate.go @@ -10,7 +10,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -161,13 +161,13 @@ func (m *TupleWithNoValidate) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *TupleWithNoValidate) UnmarshalBinary(b []byte) error { var res TupleWithNoValidate - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/external-types/models/zzz.go b/external-types/models/zzz.go index 45ab17ee..410b6ec9 100644 --- a/external-types/models/zzz.go +++ b/external-types/models/zzz.go @@ -9,7 +9,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" "github.com/go-swagger/examples/external-types/fred" custom "github.com/go-swagger/examples/external-types/fred" @@ -199,7 +200,7 @@ func (m *Zzz) Validate(formats strfmt.Registry) error { } func (m *Zzz) validateBeta(formats strfmt.Registry) error { - if swag.IsZero(m.Beta) { // not required + if typeutils.IsZero(m.Beta) { // not required return nil } @@ -230,7 +231,7 @@ func (m *Zzz) validateBeta(formats strfmt.Registry) error { } func (m *Zzz) validateDelta(formats strfmt.Registry) error { - if swag.IsZero(m.Delta) { // not required + if typeutils.IsZero(m.Delta) { // not required return nil } @@ -251,7 +252,7 @@ func (m *Zzz) validateDelta(formats strfmt.Registry) error { } func (m *Zzz) validateEpsilon(formats strfmt.Registry) error { - if swag.IsZero(m.Epsilon) { // not required + if typeutils.IsZero(m.Epsilon) { // not required return nil } @@ -276,7 +277,7 @@ func (m *Zzz) validateEpsilon(formats strfmt.Registry) error { } func (m *Zzz) validateGamma(formats strfmt.Registry) error { - if swag.IsZero(m.Gamma) { // not required + if typeutils.IsZero(m.Gamma) { // not required return nil } @@ -297,7 +298,7 @@ func (m *Zzz) validateGamma(formats strfmt.Registry) error { } func (m *Zzz) validateMeta(formats strfmt.Registry) error { - if swag.IsZero(m.Meta) { // not required + if typeutils.IsZero(m.Meta) { // not required return nil } @@ -318,7 +319,7 @@ func (m *Zzz) validateMeta(formats strfmt.Registry) error { } func (m *Zzz) validateNullableBeta(formats strfmt.Registry) error { - if swag.IsZero(m.NullableBeta) { // not required + if typeutils.IsZero(m.NullableBeta) { // not required return nil } @@ -329,7 +330,7 @@ func (m *Zzz) validateNullableBeta(formats strfmt.Registry) error { } for i := 0; i < len(m.NullableBeta); i++ { - if swag.IsZero(m.NullableBeta[i]) { // not required + if typeutils.IsZero(m.NullableBeta[i]) { // not required continue } @@ -354,7 +355,7 @@ func (m *Zzz) validateNullableBeta(formats strfmt.Registry) error { } func (m *Zzz) validateNullableDelta(formats strfmt.Registry) error { - if swag.IsZero(m.NullableDelta) { // not required + if typeutils.IsZero(m.NullableDelta) { // not required return nil } @@ -377,12 +378,12 @@ func (m *Zzz) validateNullableDelta(formats strfmt.Registry) error { } func (m *Zzz) validateNullableEpsilon(formats strfmt.Registry) error { - if swag.IsZero(m.NullableEpsilon) { // not required + if typeutils.IsZero(m.NullableEpsilon) { // not required return nil } for i := 0; i < len(m.NullableEpsilon); i++ { - if swag.IsZero(m.NullableEpsilon[i]) { // not required + if typeutils.IsZero(m.NullableEpsilon[i]) { // not required continue } @@ -407,7 +408,7 @@ func (m *Zzz) validateNullableEpsilon(formats strfmt.Registry) error { } func (m *Zzz) validateNullableGamma(formats strfmt.Registry) error { - if swag.IsZero(m.NullableGamma) { // not required + if typeutils.IsZero(m.NullableGamma) { // not required return nil } @@ -430,7 +431,7 @@ func (m *Zzz) validateNullableGamma(formats strfmt.Registry) error { } func (m *Zzz) validateNullableMeta(formats strfmt.Registry) error { - if swag.IsZero(m.NullableMeta) { // not required + if typeutils.IsZero(m.NullableMeta) { // not required return nil } @@ -598,7 +599,7 @@ func (m *Zzz) ContextValidate(ctx context.Context, formats strfmt.Registry) erro func (m *Zzz) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { - if swag.IsZero(m.Meta) { // not required + if typeutils.IsZero(m.Meta) { // not required return nil } @@ -620,7 +621,7 @@ func (m *Zzz) contextValidateMeta(ctx context.Context, formats strfmt.Registry) func (m *Zzz) contextValidateNullableMeta(ctx context.Context, formats strfmt.Registry) error { - if swag.IsZero(m.NullableMeta) { // not required + if typeutils.IsZero(m.NullableMeta) { // not required return nil } @@ -666,13 +667,13 @@ func (m *Zzz) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Zzz) UnmarshalBinary(b []byte) error { var res Zzz - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/external-types/restapi/configure_external_types_demo.go b/external-types/restapi/configure_external_types_demo.go index 8c883e5b..fe626133 100644 --- a/external-types/restapi/configure_external_types_demo.go +++ b/external-types/restapi/configure_external_types_demo.go @@ -16,7 +16,7 @@ import ( //go:generate swagger generate server --target ../../external-types --name ExternalTypesDemo --spec ../example-external-types.yaml --principal any func configureFlags(api *operations.ExternalTypesDemoAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/external-types/restapi/operations/external_types_demo_api.go b/external-types/restapi/operations/external_types_demo_api.go index 9c41a941..7a2f29ab 100644 --- a/external-types/restapi/operations/external_types_demo_api.go +++ b/external-types/restapi/operations/external_types_demo_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" ) // NewExternalTypesDemoAPI creates a new ExternalTypesDemo instance @@ -128,7 +128,7 @@ type ExternalTypesDemoAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/external-types/restapi/operations/get_stream_responses.go b/external-types/restapi/operations/get_stream_responses.go index 9bd7256d..823b70b5 100644 --- a/external-types/restapi/operations/get_stream_responses.go +++ b/external-types/restapi/operations/get_stream_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/external-types/models" ) diff --git a/external-types/restapi/operations/get_test_swagger_responses.go b/external-types/restapi/operations/get_test_swagger_responses.go index 09a76318..3d1bf876 100644 --- a/external-types/restapi/operations/get_test_swagger_responses.go +++ b/external-types/restapi/operations/get_test_swagger_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/external-types/models" ) diff --git a/external-types/restapi/operations/post_test_swagger_responses.go b/external-types/restapi/operations/post_test_swagger_responses.go index 76e13214..6b011894 100644 --- a/external-types/restapi/operations/post_test_swagger_responses.go +++ b/external-types/restapi/operations/post_test_swagger_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - custom "github.com/go-swagger/examples/external-types/fred" ) diff --git a/external-types/restapi/operations/put_test_swagger_responses.go b/external-types/restapi/operations/put_test_swagger_responses.go index 4b91a161..69d6576a 100644 --- a/external-types/restapi/operations/put_test_swagger_responses.go +++ b/external-types/restapi/operations/put_test_swagger_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - custom "github.com/go-swagger/examples/external-types/fred" ) diff --git a/external-types/restapi/server.go b/external-types/restapi/server.go index 2e1e37a9..4785e22a 100644 --- a/external-types/restapi/server.go +++ b/external-types/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/external-types/restapi/operations" ) @@ -368,7 +368,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -383,7 +383,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/file-server/client/file_upload_client.go b/file-server/client/file_upload_client.go index 3143a369..e2b49369 100644 --- a/file-server/client/file_upload_client.go +++ b/file-server/client/file_upload_client.go @@ -6,7 +6,6 @@ import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/file-server/client/uploads" ) diff --git a/file-server/restapi/configure_file_upload.go b/file-server/restapi/configure_file_upload.go index 67003815..cdf02a27 100644 --- a/file-server/restapi/configure_file_upload.go +++ b/file-server/restapi/configure_file_upload.go @@ -4,6 +4,7 @@ package restapi import ( "crypto/tls" + stderrors "errors" "fmt" "io" "log" @@ -22,7 +23,7 @@ import ( //go:generate swagger generate server --target ../../file-server --name FileUpload --spec ../swagger.yml --principal any func configureFlags(api *operations.FileUploadAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } @@ -56,7 +57,7 @@ func configureAPI(api *operations.FileUploadAPI) http.Handler { api.UploadsUploadFileHandler = uploads.UploadFileHandlerFunc(func(params uploads.UploadFileParams) middleware.Responder { if params.File == nil { - return middleware.Error(404, fmt.Errorf("no file provided")) + return middleware.Error(http.StatusNotFound, stderrors.New("no file provided")) } defer func() { _ = params.File.Close() @@ -72,12 +73,12 @@ func configureAPI(api *operations.FileUploadAPI) http.Handler { uploadCounter++ f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600) if err != nil { - return middleware.Error(500, fmt.Errorf("could not create file on server")) + return middleware.Error(http.StatusInternalServerError, stderrors.New("could not create file on server")) } n, err := io.Copy(f, params.File) if err != nil { - return middleware.Error(500, fmt.Errorf("could not upload file on server")) + return middleware.Error(http.StatusInternalServerError, stderrors.New("could not upload file on server")) } log.Printf("copied bytes %d", n) diff --git a/file-server/restapi/operations/file_upload_api.go b/file-server/restapi/operations/file_upload_api.go index 1eb52bd1..20e6b5f8 100644 --- a/file-server/restapi/operations/file_upload_api.go +++ b/file-server/restapi/operations/file_upload_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/file-server/restapi/operations/uploads" ) @@ -102,7 +102,7 @@ type FileUploadAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/file-server/restapi/server.go b/file-server/restapi/server.go index ca065c95..392242ee 100644 --- a/file-server/restapi/server.go +++ b/file-server/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/file-server/restapi/operations" ) @@ -368,7 +368,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -383,7 +383,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/flags/flag/models/error.go b/flags/flag/models/error.go index 181b96a9..bac28f38 100644 --- a/flags/flag/models/error.go +++ b/flags/flag/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/flags/flag/models/item.go b/flags/flag/models/item.go index 2e517784..2e163a96 100644 --- a/flags/flag/models/item.go +++ b/flags/flag/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/flags/flag/restapi/configure_simple_to_do_list_api.go b/flags/flag/restapi/configure_simple_to_do_list_api.go index 5986d95a..4ac7c09a 100644 --- a/flags/flag/restapi/configure_simple_to_do_list_api.go +++ b/flags/flag/restapi/configure_simple_to_do_list_api.go @@ -17,7 +17,7 @@ import ( //go:generate swagger generate server --target ../../flag --name SimpleToDoListAPI --spec ../../swagger.yml --principal any func configureFlags(api *operations.SimpleToDoListAPIAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/flags/flag/restapi/operations/simple_to_do_list_api_api.go b/flags/flag/restapi/operations/simple_to_do_list_api_api.go index c29d0bf7..130a5b2a 100644 --- a/flags/flag/restapi/operations/simple_to_do_list_api_api.go +++ b/flags/flag/restapi/operations/simple_to_do_list_api_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/flags/flag/restapi/operations/todos" ) @@ -146,7 +146,7 @@ type SimpleToDoListAPIAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/flags/flag/restapi/operations/todos/add_one_responses.go b/flags/flag/restapi/operations/todos/add_one_responses.go index 524c0cf9..d2da2f6f 100644 --- a/flags/flag/restapi/operations/todos/add_one_responses.go +++ b/flags/flag/restapi/operations/todos/add_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/flag/models" ) diff --git a/flags/flag/restapi/operations/todos/destroy_one_responses.go b/flags/flag/restapi/operations/todos/destroy_one_responses.go index 18c7673f..9079f67b 100644 --- a/flags/flag/restapi/operations/todos/destroy_one_responses.go +++ b/flags/flag/restapi/operations/todos/destroy_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/flag/models" ) diff --git a/flags/flag/restapi/operations/todos/find_parameters.go b/flags/flag/restapi/operations/todos/find_parameters.go index 860781a9..599a2858 100644 --- a/flags/flag/restapi/operations/todos/find_parameters.go +++ b/flags/flag/restapi/operations/todos/find_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -111,7 +111,7 @@ func (o *FindParams) bindXRateLimit(rawData []string, hasKey bool, formats strfm return err } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("X-Rate-Limit", "header", "int32", raw) } @@ -136,7 +136,7 @@ func (o *FindParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Reg return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "formData", "int32", raw) } @@ -161,7 +161,7 @@ func (o *FindParams) bindTags(rawData []string, hasKey bool, formats strfmt.Regi var tagsIR []int32 for i, tagsIV := range tagsIC { // items.Format: "int32" - tagsI, err := swag.ConvertInt32(tagsIV) + tagsI, err := conv.ConvertInt32(tagsIV) if err != nil { return errors.InvalidType(fmt.Sprintf("%s.%v", "tags", i), "formData", "int32", tagsI) } diff --git a/flags/flag/restapi/operations/todos/find_responses.go b/flags/flag/restapi/operations/todos/find_responses.go index 21d8987f..c82e2a2b 100644 --- a/flags/flag/restapi/operations/todos/find_responses.go +++ b/flags/flag/restapi/operations/todos/find_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/flag/models" ) diff --git a/flags/flag/restapi/operations/todos/update_one_responses.go b/flags/flag/restapi/operations/todos/update_one_responses.go index 27f518b7..b0271bef 100644 --- a/flags/flag/restapi/operations/todos/update_one_responses.go +++ b/flags/flag/restapi/operations/todos/update_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/flag/models" ) diff --git a/flags/flag/restapi/server.go b/flags/flag/restapi/server.go index 851c00f8..08e62b37 100644 --- a/flags/flag/restapi/server.go +++ b/flags/flag/restapi/server.go @@ -25,7 +25,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/flags/flag/restapi/operations" ) @@ -494,7 +494,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -509,7 +509,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/flags/go-flags/models/error.go b/flags/go-flags/models/error.go index 181b96a9..bac28f38 100644 --- a/flags/go-flags/models/error.go +++ b/flags/go-flags/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/flags/go-flags/models/item.go b/flags/go-flags/models/item.go index 2e517784..2e163a96 100644 --- a/flags/go-flags/models/item.go +++ b/flags/go-flags/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/flags/go-flags/restapi/configure_simple_to_do_list_api.go b/flags/go-flags/restapi/configure_simple_to_do_list_api.go index 93f4ab4d..ffa3f08c 100644 --- a/flags/go-flags/restapi/configure_simple_to_do_list_api.go +++ b/flags/go-flags/restapi/configure_simple_to_do_list_api.go @@ -17,7 +17,7 @@ import ( //go:generate swagger generate server --target ../../go-flags --name SimpleToDoListAPI --spec ../../swagger.yml --principal any func configureFlags(api *operations.SimpleToDoListAPIAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/flags/go-flags/restapi/operations/simple_to_do_list_api_api.go b/flags/go-flags/restapi/operations/simple_to_do_list_api_api.go index 1dc53f75..95fccccf 100644 --- a/flags/go-flags/restapi/operations/simple_to_do_list_api_api.go +++ b/flags/go-flags/restapi/operations/simple_to_do_list_api_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/flags/go-flags/restapi/operations/todos" ) @@ -146,7 +146,7 @@ type SimpleToDoListAPIAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/flags/go-flags/restapi/operations/todos/add_one_responses.go b/flags/go-flags/restapi/operations/todos/add_one_responses.go index 72fbfa49..7110f897 100644 --- a/flags/go-flags/restapi/operations/todos/add_one_responses.go +++ b/flags/go-flags/restapi/operations/todos/add_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/go-flags/models" ) diff --git a/flags/go-flags/restapi/operations/todos/destroy_one_responses.go b/flags/go-flags/restapi/operations/todos/destroy_one_responses.go index 42665118..e28985fd 100644 --- a/flags/go-flags/restapi/operations/todos/destroy_one_responses.go +++ b/flags/go-flags/restapi/operations/todos/destroy_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/go-flags/models" ) diff --git a/flags/go-flags/restapi/operations/todos/find_parameters.go b/flags/go-flags/restapi/operations/todos/find_parameters.go index 860781a9..599a2858 100644 --- a/flags/go-flags/restapi/operations/todos/find_parameters.go +++ b/flags/go-flags/restapi/operations/todos/find_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -111,7 +111,7 @@ func (o *FindParams) bindXRateLimit(rawData []string, hasKey bool, formats strfm return err } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("X-Rate-Limit", "header", "int32", raw) } @@ -136,7 +136,7 @@ func (o *FindParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Reg return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "formData", "int32", raw) } @@ -161,7 +161,7 @@ func (o *FindParams) bindTags(rawData []string, hasKey bool, formats strfmt.Regi var tagsIR []int32 for i, tagsIV := range tagsIC { // items.Format: "int32" - tagsI, err := swag.ConvertInt32(tagsIV) + tagsI, err := conv.ConvertInt32(tagsIV) if err != nil { return errors.InvalidType(fmt.Sprintf("%s.%v", "tags", i), "formData", "int32", tagsI) } diff --git a/flags/go-flags/restapi/operations/todos/find_responses.go b/flags/go-flags/restapi/operations/todos/find_responses.go index ff3f45eb..3a288a91 100644 --- a/flags/go-flags/restapi/operations/todos/find_responses.go +++ b/flags/go-flags/restapi/operations/todos/find_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/go-flags/models" ) diff --git a/flags/go-flags/restapi/operations/todos/update_one_responses.go b/flags/go-flags/restapi/operations/todos/update_one_responses.go index 17ccfa99..33a8ccf8 100644 --- a/flags/go-flags/restapi/operations/todos/update_one_responses.go +++ b/flags/go-flags/restapi/operations/todos/update_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/go-flags/models" ) diff --git a/flags/go-flags/restapi/server.go b/flags/go-flags/restapi/server.go index e7202812..4407d298 100644 --- a/flags/go-flags/restapi/server.go +++ b/flags/go-flags/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/flags/go-flags/restapi/operations" ) @@ -370,7 +370,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -385,7 +385,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/flags/pflag/models/error.go b/flags/pflag/models/error.go index 181b96a9..bac28f38 100644 --- a/flags/pflag/models/error.go +++ b/flags/pflag/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/flags/pflag/models/item.go b/flags/pflag/models/item.go index 2e517784..2e163a96 100644 --- a/flags/pflag/models/item.go +++ b/flags/pflag/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/flags/pflag/restapi/configure_simple_to_do_list_api.go b/flags/pflag/restapi/configure_simple_to_do_list_api.go index b195fe9f..2155e29d 100644 --- a/flags/pflag/restapi/configure_simple_to_do_list_api.go +++ b/flags/pflag/restapi/configure_simple_to_do_list_api.go @@ -17,7 +17,7 @@ import ( //go:generate swagger generate server --target ../../pflag --name SimpleToDoListAPI --spec ../../swagger.yml --principal any func configureFlags(api *operations.SimpleToDoListAPIAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/flags/pflag/restapi/operations/simple_to_do_list_api_api.go b/flags/pflag/restapi/operations/simple_to_do_list_api_api.go index b668c829..d0b99c47 100644 --- a/flags/pflag/restapi/operations/simple_to_do_list_api_api.go +++ b/flags/pflag/restapi/operations/simple_to_do_list_api_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/flags/pflag/restapi/operations/todos" ) @@ -146,7 +146,7 @@ type SimpleToDoListAPIAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/flags/pflag/restapi/operations/todos/add_one_responses.go b/flags/pflag/restapi/operations/todos/add_one_responses.go index 8b6faeed..c866dceb 100644 --- a/flags/pflag/restapi/operations/todos/add_one_responses.go +++ b/flags/pflag/restapi/operations/todos/add_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/pflag/models" ) diff --git a/flags/pflag/restapi/operations/todos/destroy_one_responses.go b/flags/pflag/restapi/operations/todos/destroy_one_responses.go index 56f620f9..919f5a44 100644 --- a/flags/pflag/restapi/operations/todos/destroy_one_responses.go +++ b/flags/pflag/restapi/operations/todos/destroy_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/pflag/models" ) diff --git a/flags/pflag/restapi/operations/todos/find_parameters.go b/flags/pflag/restapi/operations/todos/find_parameters.go index 860781a9..599a2858 100644 --- a/flags/pflag/restapi/operations/todos/find_parameters.go +++ b/flags/pflag/restapi/operations/todos/find_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -111,7 +111,7 @@ func (o *FindParams) bindXRateLimit(rawData []string, hasKey bool, formats strfm return err } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("X-Rate-Limit", "header", "int32", raw) } @@ -136,7 +136,7 @@ func (o *FindParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Reg return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "formData", "int32", raw) } @@ -161,7 +161,7 @@ func (o *FindParams) bindTags(rawData []string, hasKey bool, formats strfmt.Regi var tagsIR []int32 for i, tagsIV := range tagsIC { // items.Format: "int32" - tagsI, err := swag.ConvertInt32(tagsIV) + tagsI, err := conv.ConvertInt32(tagsIV) if err != nil { return errors.InvalidType(fmt.Sprintf("%s.%v", "tags", i), "formData", "int32", tagsI) } diff --git a/flags/pflag/restapi/operations/todos/find_responses.go b/flags/pflag/restapi/operations/todos/find_responses.go index f861bd3f..0bf51457 100644 --- a/flags/pflag/restapi/operations/todos/find_responses.go +++ b/flags/pflag/restapi/operations/todos/find_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/pflag/models" ) diff --git a/flags/pflag/restapi/operations/todos/update_one_responses.go b/flags/pflag/restapi/operations/todos/update_one_responses.go index 10d56e98..58817ed6 100644 --- a/flags/pflag/restapi/operations/todos/update_one_responses.go +++ b/flags/pflag/restapi/operations/todos/update_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/pflag/models" ) diff --git a/flags/pflag/restapi/server.go b/flags/pflag/restapi/server.go index 995d3676..060937e9 100644 --- a/flags/pflag/restapi/server.go +++ b/flags/pflag/restapi/server.go @@ -23,7 +23,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/flags/pflag/restapi/operations" ) @@ -473,7 +473,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -488,7 +488,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/flags/xflag/models/error.go b/flags/xflag/models/error.go index 181b96a9..bac28f38 100644 --- a/flags/xflag/models/error.go +++ b/flags/xflag/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/flags/xflag/models/item.go b/flags/xflag/models/item.go index 2e517784..2e163a96 100644 --- a/flags/xflag/models/item.go +++ b/flags/xflag/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/flags/xflag/restapi/configure_simple_to_do_list_api.go b/flags/xflag/restapi/configure_simple_to_do_list_api.go index e6ca6c4d..418fd5e9 100644 --- a/flags/xflag/restapi/configure_simple_to_do_list_api.go +++ b/flags/xflag/restapi/configure_simple_to_do_list_api.go @@ -17,7 +17,7 @@ import ( //go:generate swagger generate server --target ../../xflag --name SimpleToDoListAPI --spec ../../swagger.yml --principal any --exclude-spec func configureFlags(api *operations.SimpleToDoListAPIAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/flags/xflag/restapi/operations/simple_to_do_list_api_api.go b/flags/xflag/restapi/operations/simple_to_do_list_api_api.go index afc3a713..e150474b 100644 --- a/flags/xflag/restapi/operations/simple_to_do_list_api_api.go +++ b/flags/xflag/restapi/operations/simple_to_do_list_api_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/flags/xflag/restapi/operations/todos" ) @@ -146,7 +146,7 @@ type SimpleToDoListAPIAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/flags/xflag/restapi/operations/todos/add_one_responses.go b/flags/xflag/restapi/operations/todos/add_one_responses.go index 59679c16..c81e6e08 100644 --- a/flags/xflag/restapi/operations/todos/add_one_responses.go +++ b/flags/xflag/restapi/operations/todos/add_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/xflag/models" ) diff --git a/flags/xflag/restapi/operations/todos/destroy_one_responses.go b/flags/xflag/restapi/operations/todos/destroy_one_responses.go index 485ff754..ad3eb1f3 100644 --- a/flags/xflag/restapi/operations/todos/destroy_one_responses.go +++ b/flags/xflag/restapi/operations/todos/destroy_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/xflag/models" ) diff --git a/flags/xflag/restapi/operations/todos/find_parameters.go b/flags/xflag/restapi/operations/todos/find_parameters.go index 860781a9..599a2858 100644 --- a/flags/xflag/restapi/operations/todos/find_parameters.go +++ b/flags/xflag/restapi/operations/todos/find_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -111,7 +111,7 @@ func (o *FindParams) bindXRateLimit(rawData []string, hasKey bool, formats strfm return err } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("X-Rate-Limit", "header", "int32", raw) } @@ -136,7 +136,7 @@ func (o *FindParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Reg return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "formData", "int32", raw) } @@ -161,7 +161,7 @@ func (o *FindParams) bindTags(rawData []string, hasKey bool, formats strfmt.Regi var tagsIR []int32 for i, tagsIV := range tagsIC { // items.Format: "int32" - tagsI, err := swag.ConvertInt32(tagsIV) + tagsI, err := conv.ConvertInt32(tagsIV) if err != nil { return errors.InvalidType(fmt.Sprintf("%s.%v", "tags", i), "formData", "int32", tagsI) } diff --git a/flags/xflag/restapi/operations/todos/find_responses.go b/flags/xflag/restapi/operations/todos/find_responses.go index c0a9f557..2e7e719e 100644 --- a/flags/xflag/restapi/operations/todos/find_responses.go +++ b/flags/xflag/restapi/operations/todos/find_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/xflag/models" ) diff --git a/flags/xflag/restapi/operations/todos/update_one_responses.go b/flags/xflag/restapi/operations/todos/update_one_responses.go index cf3f61ee..7d532c34 100644 --- a/flags/xflag/restapi/operations/todos/update_one_responses.go +++ b/flags/xflag/restapi/operations/todos/update_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/xflag/models" ) diff --git a/flags/xflag/restapi/server.go b/flags/xflag/restapi/server.go index 187d585c..23bee361 100644 --- a/flags/xflag/restapi/server.go +++ b/flags/xflag/restapi/server.go @@ -25,7 +25,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/flags/xflag/restapi/operations" ) @@ -498,7 +498,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -513,7 +513,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/flags/xgo-flags/models/error.go b/flags/xgo-flags/models/error.go index 181b96a9..bac28f38 100644 --- a/flags/xgo-flags/models/error.go +++ b/flags/xgo-flags/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/flags/xgo-flags/models/item.go b/flags/xgo-flags/models/item.go index 2e517784..2e163a96 100644 --- a/flags/xgo-flags/models/item.go +++ b/flags/xgo-flags/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/flags/xgo-flags/restapi/configure_simple_to_do_list_api.go b/flags/xgo-flags/restapi/configure_simple_to_do_list_api.go index 0829de45..e2b96b75 100644 --- a/flags/xgo-flags/restapi/configure_simple_to_do_list_api.go +++ b/flags/xgo-flags/restapi/configure_simple_to_do_list_api.go @@ -17,7 +17,7 @@ import ( //go:generate swagger generate server --target ../../xgo-flags --name SimpleToDoListAPI --spec ../../swagger.yml --principal any --exclude-spec func configureFlags(api *operations.SimpleToDoListAPIAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/flags/xgo-flags/restapi/operations/simple_to_do_list_api_api.go b/flags/xgo-flags/restapi/operations/simple_to_do_list_api_api.go index 42271826..9037353b 100644 --- a/flags/xgo-flags/restapi/operations/simple_to_do_list_api_api.go +++ b/flags/xgo-flags/restapi/operations/simple_to_do_list_api_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/flags/xgo-flags/restapi/operations/todos" ) @@ -146,7 +146,7 @@ type SimpleToDoListAPIAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/flags/xgo-flags/restapi/operations/todos/add_one_responses.go b/flags/xgo-flags/restapi/operations/todos/add_one_responses.go index 1778c4ae..ae5c1847 100644 --- a/flags/xgo-flags/restapi/operations/todos/add_one_responses.go +++ b/flags/xgo-flags/restapi/operations/todos/add_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/xgo-flags/models" ) diff --git a/flags/xgo-flags/restapi/operations/todos/destroy_one_responses.go b/flags/xgo-flags/restapi/operations/todos/destroy_one_responses.go index a96b228a..75272bcc 100644 --- a/flags/xgo-flags/restapi/operations/todos/destroy_one_responses.go +++ b/flags/xgo-flags/restapi/operations/todos/destroy_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/xgo-flags/models" ) diff --git a/flags/xgo-flags/restapi/operations/todos/find_parameters.go b/flags/xgo-flags/restapi/operations/todos/find_parameters.go index 860781a9..599a2858 100644 --- a/flags/xgo-flags/restapi/operations/todos/find_parameters.go +++ b/flags/xgo-flags/restapi/operations/todos/find_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -111,7 +111,7 @@ func (o *FindParams) bindXRateLimit(rawData []string, hasKey bool, formats strfm return err } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("X-Rate-Limit", "header", "int32", raw) } @@ -136,7 +136,7 @@ func (o *FindParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Reg return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "formData", "int32", raw) } @@ -161,7 +161,7 @@ func (o *FindParams) bindTags(rawData []string, hasKey bool, formats strfmt.Regi var tagsIR []int32 for i, tagsIV := range tagsIC { // items.Format: "int32" - tagsI, err := swag.ConvertInt32(tagsIV) + tagsI, err := conv.ConvertInt32(tagsIV) if err != nil { return errors.InvalidType(fmt.Sprintf("%s.%v", "tags", i), "formData", "int32", tagsI) } diff --git a/flags/xgo-flags/restapi/operations/todos/find_responses.go b/flags/xgo-flags/restapi/operations/todos/find_responses.go index 0efec751..864dfa32 100644 --- a/flags/xgo-flags/restapi/operations/todos/find_responses.go +++ b/flags/xgo-flags/restapi/operations/todos/find_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/xgo-flags/models" ) diff --git a/flags/xgo-flags/restapi/operations/todos/update_one_responses.go b/flags/xgo-flags/restapi/operations/todos/update_one_responses.go index 90b72695..d60a2c18 100644 --- a/flags/xgo-flags/restapi/operations/todos/update_one_responses.go +++ b/flags/xgo-flags/restapi/operations/todos/update_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/xgo-flags/models" ) diff --git a/flags/xgo-flags/restapi/server.go b/flags/xgo-flags/restapi/server.go index 9f51e172..e4e1b42a 100644 --- a/flags/xgo-flags/restapi/server.go +++ b/flags/xgo-flags/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/flags/xgo-flags/restapi/operations" ) @@ -371,7 +371,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -386,7 +386,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/flags/xpflag/models/error.go b/flags/xpflag/models/error.go index 181b96a9..bac28f38 100644 --- a/flags/xpflag/models/error.go +++ b/flags/xpflag/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/flags/xpflag/models/item.go b/flags/xpflag/models/item.go index 2e517784..2e163a96 100644 --- a/flags/xpflag/models/item.go +++ b/flags/xpflag/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/flags/xpflag/restapi/configure_simple_to_do_list_api.go b/flags/xpflag/restapi/configure_simple_to_do_list_api.go index 8951e086..60c0a09a 100644 --- a/flags/xpflag/restapi/configure_simple_to_do_list_api.go +++ b/flags/xpflag/restapi/configure_simple_to_do_list_api.go @@ -17,7 +17,7 @@ import ( //go:generate swagger generate server --target ../../xpflag --name SimpleToDoListAPI --spec ../../swagger.yml --principal any --exclude-spec func configureFlags(api *operations.SimpleToDoListAPIAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/flags/xpflag/restapi/operations/simple_to_do_list_api_api.go b/flags/xpflag/restapi/operations/simple_to_do_list_api_api.go index b00fee94..0f106a7f 100644 --- a/flags/xpflag/restapi/operations/simple_to_do_list_api_api.go +++ b/flags/xpflag/restapi/operations/simple_to_do_list_api_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/flags/xpflag/restapi/operations/todos" ) @@ -146,7 +146,7 @@ type SimpleToDoListAPIAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/flags/xpflag/restapi/operations/todos/add_one_responses.go b/flags/xpflag/restapi/operations/todos/add_one_responses.go index 5d6e08ff..34de0307 100644 --- a/flags/xpflag/restapi/operations/todos/add_one_responses.go +++ b/flags/xpflag/restapi/operations/todos/add_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/xpflag/models" ) diff --git a/flags/xpflag/restapi/operations/todos/destroy_one_responses.go b/flags/xpflag/restapi/operations/todos/destroy_one_responses.go index 90709cb4..2345374f 100644 --- a/flags/xpflag/restapi/operations/todos/destroy_one_responses.go +++ b/flags/xpflag/restapi/operations/todos/destroy_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/xpflag/models" ) diff --git a/flags/xpflag/restapi/operations/todos/find_parameters.go b/flags/xpflag/restapi/operations/todos/find_parameters.go index 860781a9..599a2858 100644 --- a/flags/xpflag/restapi/operations/todos/find_parameters.go +++ b/flags/xpflag/restapi/operations/todos/find_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -111,7 +111,7 @@ func (o *FindParams) bindXRateLimit(rawData []string, hasKey bool, formats strfm return err } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("X-Rate-Limit", "header", "int32", raw) } @@ -136,7 +136,7 @@ func (o *FindParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Reg return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "formData", "int32", raw) } @@ -161,7 +161,7 @@ func (o *FindParams) bindTags(rawData []string, hasKey bool, formats strfmt.Regi var tagsIR []int32 for i, tagsIV := range tagsIC { // items.Format: "int32" - tagsI, err := swag.ConvertInt32(tagsIV) + tagsI, err := conv.ConvertInt32(tagsIV) if err != nil { return errors.InvalidType(fmt.Sprintf("%s.%v", "tags", i), "formData", "int32", tagsI) } diff --git a/flags/xpflag/restapi/operations/todos/find_responses.go b/flags/xpflag/restapi/operations/todos/find_responses.go index 51c1c43f..3bb17338 100644 --- a/flags/xpflag/restapi/operations/todos/find_responses.go +++ b/flags/xpflag/restapi/operations/todos/find_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/xpflag/models" ) diff --git a/flags/xpflag/restapi/operations/todos/update_one_responses.go b/flags/xpflag/restapi/operations/todos/update_one_responses.go index 19e38857..50398b52 100644 --- a/flags/xpflag/restapi/operations/todos/update_one_responses.go +++ b/flags/xpflag/restapi/operations/todos/update_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/flags/xpflag/models" ) diff --git a/flags/xpflag/restapi/server.go b/flags/xpflag/restapi/server.go index 1bc52f0f..02a94219 100644 --- a/flags/xpflag/restapi/server.go +++ b/flags/xpflag/restapi/server.go @@ -23,7 +23,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/flags/xpflag/restapi/operations" ) @@ -477,7 +477,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -492,7 +492,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/generated/models/category.go b/generated/models/category.go index 6a479df4..d7e2973b 100644 --- a/generated/models/category.go +++ b/generated/models/category.go @@ -6,7 +6,7 @@ import ( "context" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // Category category @@ -36,13 +36,13 @@ func (m *Category) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Category) UnmarshalBinary(b []byte) error { var res Category - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/generated/models/order.go b/generated/models/order.go index 76d9a8a3..5f1c7ea8 100644 --- a/generated/models/order.go +++ b/generated/models/order.go @@ -7,7 +7,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) @@ -51,7 +52,7 @@ func (m *Order) Validate(formats strfmt.Registry) error { } func (m *Order) validateShipDate(formats strfmt.Registry) error { - if swag.IsZero(m.ShipDate) { // not required + if typeutils.IsZero(m.ShipDate) { // not required return nil } @@ -72,13 +73,13 @@ func (m *Order) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Order) UnmarshalBinary(b []byte) error { var res Order - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/generated/models/pet.go b/generated/models/pet.go index f3977f35..45e236e4 100644 --- a/generated/models/pet.go +++ b/generated/models/pet.go @@ -9,7 +9,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) @@ -67,7 +68,7 @@ func (m *Pet) Validate(formats strfmt.Registry) error { } func (m *Pet) validateCategory(formats strfmt.Registry) error { - if swag.IsZero(m.Category) { // not required + if typeutils.IsZero(m.Category) { // not required return nil } @@ -108,12 +109,12 @@ func (m *Pet) validatePhotoUrls(formats strfmt.Registry) error { } func (m *Pet) validateTags(formats strfmt.Registry) error { - if swag.IsZero(m.Tags) { // not required + if typeutils.IsZero(m.Tags) { // not required return nil } for i := 0; i < len(m.Tags); i++ { - if swag.IsZero(m.Tags[i]) { // not required + if typeutils.IsZero(m.Tags[i]) { // not required continue } @@ -159,7 +160,7 @@ func (m *Pet) contextValidateCategory(ctx context.Context, formats strfmt.Regist if m.Category != nil { - if swag.IsZero(m.Category) { // not required + if typeutils.IsZero(m.Category) { // not required return nil } @@ -186,7 +187,7 @@ func (m *Pet) contextValidateTags(ctx context.Context, formats strfmt.Registry) if m.Tags[i] != nil { - if swag.IsZero(m.Tags[i]) { // not required + if typeutils.IsZero(m.Tags[i]) { // not required return nil } @@ -214,13 +215,13 @@ func (m *Pet) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Pet) UnmarshalBinary(b []byte) error { var res Pet - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/generated/models/tag.go b/generated/models/tag.go index cde149f0..e4ccda03 100644 --- a/generated/models/tag.go +++ b/generated/models/tag.go @@ -6,7 +6,7 @@ import ( "context" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // Tag tag @@ -36,13 +36,13 @@ func (m *Tag) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Tag) UnmarshalBinary(b []byte) error { var res Tag - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/generated/models/user.go b/generated/models/user.go index 04e76a02..5c696c4f 100644 --- a/generated/models/user.go +++ b/generated/models/user.go @@ -6,7 +6,7 @@ import ( "context" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // User user @@ -54,13 +54,13 @@ func (m *User) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *User) UnmarshalBinary(b []byte) error { var res User - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/generated/restapi/configure_petstore.go b/generated/restapi/configure_petstore.go index 5a6cfa19..8df999f7 100644 --- a/generated/restapi/configure_petstore.go +++ b/generated/restapi/configure_petstore.go @@ -19,7 +19,7 @@ import ( //go:generate swagger generate server --target ../../generated --name Petstore --spec ../swagger-petstore.json --principal any func configureFlags(api *operations.PetstoreAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/generated/restapi/operations/pet/delete_pet_parameters.go b/generated/restapi/operations/pet/delete_pet_parameters.go index 63ce2022..e552d74b 100644 --- a/generated/restapi/operations/pet/delete_pet_parameters.go +++ b/generated/restapi/operations/pet/delete_pet_parameters.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -94,7 +94,7 @@ func (o *DeletePetParams) bindPetID(rawData []string, hasKey bool, formats strfm // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("petId", "path", "int64", raw) } diff --git a/generated/restapi/operations/pet/delete_pet_urlbuilder.go b/generated/restapi/operations/pet/delete_pet_urlbuilder.go index 6e3d7977..585c28cc 100644 --- a/generated/restapi/operations/pet/delete_pet_urlbuilder.go +++ b/generated/restapi/operations/pet/delete_pet_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // DeletePetURL generates an URL for the delete pet operation @@ -41,7 +41,7 @@ func (o *DeletePetURL) Build() (*url.URL, error) { var _path = "/pets/{petId}" - petID := swag.FormatInt64(o.PetID) + petID := conv.FormatInteger(o.PetID) if petID != "" { _path = strings.ReplaceAll(_path, "{petId}", petID) } else { diff --git a/generated/restapi/operations/pet/find_pets_by_status_responses.go b/generated/restapi/operations/pet/find_pets_by_status_responses.go index 8be9e724..a375e97a 100644 --- a/generated/restapi/operations/pet/find_pets_by_status_responses.go +++ b/generated/restapi/operations/pet/find_pets_by_status_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/generated/models" ) diff --git a/generated/restapi/operations/pet/find_pets_by_status_urlbuilder.go b/generated/restapi/operations/pet/find_pets_by_status_urlbuilder.go index 7ae67021..0137f05e 100644 --- a/generated/restapi/operations/pet/find_pets_by_status_urlbuilder.go +++ b/generated/restapi/operations/pet/find_pets_by_status_urlbuilder.go @@ -7,7 +7,7 @@ import ( "net/url" golangswaggerpaths "path" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/stringutils" ) // FindPetsByStatusURL generates an URL for the find pets by status operation @@ -56,7 +56,7 @@ func (o *FindPetsByStatusURL) Build() (*url.URL, error) { } } - status := swag.JoinByFormat(statusIR, "multi") + status := stringutils.JoinByFormat(statusIR, "multi") for _, qsv := range status { qs.Add("status", qsv) diff --git a/generated/restapi/operations/pet/find_pets_by_tags_responses.go b/generated/restapi/operations/pet/find_pets_by_tags_responses.go index 34c1dd08..56a84bf4 100644 --- a/generated/restapi/operations/pet/find_pets_by_tags_responses.go +++ b/generated/restapi/operations/pet/find_pets_by_tags_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/generated/models" ) diff --git a/generated/restapi/operations/pet/find_pets_by_tags_urlbuilder.go b/generated/restapi/operations/pet/find_pets_by_tags_urlbuilder.go index f44a220e..10dd77cb 100644 --- a/generated/restapi/operations/pet/find_pets_by_tags_urlbuilder.go +++ b/generated/restapi/operations/pet/find_pets_by_tags_urlbuilder.go @@ -7,7 +7,7 @@ import ( "net/url" golangswaggerpaths "path" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/stringutils" ) // FindPetsByTagsURL generates an URL for the find pets by tags operation @@ -56,7 +56,7 @@ func (o *FindPetsByTagsURL) Build() (*url.URL, error) { } } - tags := swag.JoinByFormat(tagsIR, "multi") + tags := stringutils.JoinByFormat(tagsIR, "multi") for _, qsv := range tags { qs.Add("tags", qsv) diff --git a/generated/restapi/operations/pet/get_pet_by_id_parameters.go b/generated/restapi/operations/pet/get_pet_by_id_parameters.go index 18ae7ca7..d69b98b0 100644 --- a/generated/restapi/operations/pet/get_pet_by_id_parameters.go +++ b/generated/restapi/operations/pet/get_pet_by_id_parameters.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewGetPetByIDParams creates a new GetPetByIDParams object @@ -63,7 +63,7 @@ func (o *GetPetByIDParams) bindPetID(rawData []string, hasKey bool, formats strf // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("petId", "path", "int64", raw) } diff --git a/generated/restapi/operations/pet/get_pet_by_id_responses.go b/generated/restapi/operations/pet/get_pet_by_id_responses.go index fb20adfc..f28e8d5c 100644 --- a/generated/restapi/operations/pet/get_pet_by_id_responses.go +++ b/generated/restapi/operations/pet/get_pet_by_id_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/generated/models" ) diff --git a/generated/restapi/operations/pet/get_pet_by_id_urlbuilder.go b/generated/restapi/operations/pet/get_pet_by_id_urlbuilder.go index 51ef769a..ab4e580c 100644 --- a/generated/restapi/operations/pet/get_pet_by_id_urlbuilder.go +++ b/generated/restapi/operations/pet/get_pet_by_id_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // GetPetByIDURL generates an URL for the get pet by Id operation @@ -41,7 +41,7 @@ func (o *GetPetByIDURL) Build() (*url.URL, error) { var _path = "/pets/{petId}" - petID := swag.FormatInt64(o.PetID) + petID := conv.FormatInteger(o.PetID) if petID != "" { _path = strings.ReplaceAll(_path, "{petId}", petID) } else { diff --git a/generated/restapi/operations/petstore_api.go b/generated/restapi/operations/petstore_api.go index 0395a1b8..34c553a5 100644 --- a/generated/restapi/operations/petstore_api.go +++ b/generated/restapi/operations/petstore_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/generated/restapi/operations/pet" "github.com/go-swagger/examples/generated/restapi/operations/store" @@ -287,7 +287,7 @@ type PetstoreAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/generated/restapi/operations/store/get_order_by_id_responses.go b/generated/restapi/operations/store/get_order_by_id_responses.go index d0c77478..4674d050 100644 --- a/generated/restapi/operations/store/get_order_by_id_responses.go +++ b/generated/restapi/operations/store/get_order_by_id_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/generated/models" ) diff --git a/generated/restapi/operations/store/place_order_responses.go b/generated/restapi/operations/store/place_order_responses.go index 577ca68e..24223658 100644 --- a/generated/restapi/operations/store/place_order_responses.go +++ b/generated/restapi/operations/store/place_order_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/generated/models" ) diff --git a/generated/restapi/operations/user/get_user_by_name_responses.go b/generated/restapi/operations/user/get_user_by_name_responses.go index 9d6ebc5a..c393f41a 100644 --- a/generated/restapi/operations/user/get_user_by_name_responses.go +++ b/generated/restapi/operations/user/get_user_by_name_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/generated/models" ) diff --git a/generated/restapi/server.go b/generated/restapi/server.go index 93c10a41..93014e01 100644 --- a/generated/restapi/server.go +++ b/generated/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/generated/restapi/operations" ) @@ -368,7 +368,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -383,7 +383,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/go.mod b/go.mod index 87e265b0..437997cc 100644 --- a/go.mod +++ b/go.mod @@ -4,13 +4,18 @@ go 1.25.0 require ( github.com/coreos/go-oidc/v3 v3.18.0 - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/go-openapi/errors v0.22.7 github.com/go-openapi/loads v0.23.3 - github.com/go-openapi/runtime v0.30.0 + github.com/go-openapi/runtime v0.31.0 github.com/go-openapi/spec v0.22.4 github.com/go-openapi/strfmt v0.26.2 - github.com/go-openapi/swag v0.26.0 + github.com/go-openapi/swag/cmdutils v0.26.0 + github.com/go-openapi/swag/conv v0.26.0 + github.com/go-openapi/swag/jsonutils v0.26.0 + github.com/go-openapi/swag/netutils v0.26.0 + github.com/go-openapi/swag/stringutils v0.26.0 + github.com/go-openapi/swag/typeutils v0.26.0 + github.com/go-openapi/testify/v2 v2.5.1 github.com/go-openapi/validate v0.25.2 github.com/golang-jwt/jwt/v5 v5.3.1 github.com/jessevdk/go-flags v1.6.1 @@ -32,17 +37,11 @@ require ( github.com/go-openapi/analysis v0.25.0 // indirect github.com/go-openapi/jsonpointer v0.23.1 // indirect github.com/go-openapi/jsonreference v0.21.5 // indirect - github.com/go-openapi/runtime/server-middleware v0.30.0 // indirect - github.com/go-openapi/swag/cmdutils v0.26.0 // indirect - github.com/go-openapi/swag/conv v0.26.0 // indirect + github.com/go-openapi/runtime/server-middleware v0.31.0 // indirect github.com/go-openapi/swag/fileutils v0.26.0 // indirect github.com/go-openapi/swag/jsonname v0.26.0 // indirect - github.com/go-openapi/swag/jsonutils v0.26.0 // indirect github.com/go-openapi/swag/loading v0.26.0 // indirect github.com/go-openapi/swag/mangling v0.26.0 // indirect - github.com/go-openapi/swag/netutils v0.26.0 // indirect - github.com/go-openapi/swag/stringutils v0.26.0 // indirect - github.com/go-openapi/swag/typeutils v0.26.0 // indirect github.com/go-openapi/swag/yamlutils v0.26.0 // indirect github.com/go-viper/mapstructure/v2 v2.5.0 // indirect github.com/google/uuid v1.6.0 // indirect diff --git a/go.sum b/go.sum index 1708936c..2ca4f59c 100644 --- a/go.sum +++ b/go.sum @@ -5,8 +5,8 @@ github.com/coreos/go-oidc/v3 v3.18.0/go.mod h1:DYCf24+ncYi+XkIH97GY1+dqoRlbaSI26 github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= @@ -32,14 +32,16 @@ github.com/go-openapi/loads v0.23.3 h1:g5Xap1JfwKkUnZdn+S0L3SzBDpcTIYzZ5Qaag0YDk github.com/go-openapi/loads v0.23.3/go.mod h1:NOH07zLajXo8y55hom0omlHWDVVvCwBM/S+csCK8LqA= github.com/go-openapi/runtime v0.30.0 h1:1llnyZcqkjm77VhM4FPO1O1rt2SzLZIRPkZAY4wv4mw= github.com/go-openapi/runtime v0.30.0/go.mod h1:QtJGUq+1S0VWPP+LQldH6o4tcqGsjzTVjn/wIWEn9o4= +github.com/go-openapi/runtime v0.31.0 h1:vhmlo1LMjGXYTlYB0eFm0tTVuAidDHtmrL1nAABzUCg= +github.com/go-openapi/runtime v0.31.0/go.mod h1:fZnoje1YWt7IrH/fHBOS1h9+VzeS1d0cHj8TTkZOaRc= github.com/go-openapi/runtime/server-middleware v0.30.0 h1:8rPoJ/xv7JL8BsovaqboKETlpWBArVh8n+0L/GyePog= github.com/go-openapi/runtime/server-middleware v0.30.0/go.mod h1:OYNT/TxNvB/VK5oe4htM2jDTwlEXuejVJmu0DVZfAMs= +github.com/go-openapi/runtime/server-middleware v0.31.0 h1:zKh3KY+WJwuNd+hxbOs2ZUNlH5tF8rS3qrE5yTAWKKo= +github.com/go-openapi/runtime/server-middleware v0.31.0/go.mod h1:OYNT/TxNvB/VK5oe4htM2jDTwlEXuejVJmu0DVZfAMs= github.com/go-openapi/spec v0.22.4 h1:4pxGjipMKu0FzFiu/DPwN3CTBRlVM2yLf/YTWorYfDQ= github.com/go-openapi/spec v0.22.4/go.mod h1:WQ6Ai0VPWMZgMT4XySjlRIE6GP1bGQOtEThn3gcWLtQ= github.com/go-openapi/strfmt v0.26.2 h1:ysjheCh4i1rmFEo2LanhELDNucNzfWTZhUDKgWWPaFM= github.com/go-openapi/strfmt v0.26.2/go.mod h1:fXh1e449cyUn2NYuz+wb3wARBUdMl7qPEZwX00nqivY= -github.com/go-openapi/swag v0.26.0 h1:GVDXCmfvhfu1BxiHo8/FA+BbKmhecHnG3varjON5/RI= -github.com/go-openapi/swag v0.26.0/go.mod h1:82g3193sZJRbocs7bNCqGfIgq8pkuwVwCfhKIRlEQF0= github.com/go-openapi/swag/cmdutils v0.26.0 h1:iowihOcvq7y4egO8cOq0dmfohz6wfeQ63U1EnuhO2TU= github.com/go-openapi/swag/cmdutils v0.26.0/go.mod h1:Sm1MVFMkF6guJJ+pQqHnQA3N0j9qALV3NxzDSv6bETM= github.com/go-openapi/swag/conv v0.26.0 h1:5yGGsPYI1ZCva93U0AoKi/iZrNhaJEjr324YVsiD89I= @@ -66,8 +68,8 @@ github.com/go-openapi/swag/yamlutils v0.26.0 h1:H7O8l/8NJJQ/oiReEN+oMpnGMyt8G0hl github.com/go-openapi/swag/yamlutils v0.26.0/go.mod h1:1evKEGAtP37Pkwcc7EWMF0hedX0/x3Rkvei2wtG/TbU= github.com/go-openapi/testify/enable/yaml/v2 v2.5.0 h1:3hZD1fwydvCx/cc1R2uYNQirHqf2s6lqpKV3FcNTURA= github.com/go-openapi/testify/enable/yaml/v2 v2.5.0/go.mod h1:TvDZKBH7ZbMaF3EqH2AwTvNQCmzyZq8K1agRjf1B+Nk= -github.com/go-openapi/testify/v2 v2.5.0 h1:UOCr63aAsMIDydZbZGqo5Ev01D4eydItRbekDuZMJLw= -github.com/go-openapi/testify/v2 v2.5.0/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw= +github.com/go-openapi/testify/v2 v2.5.1 h1:TMdhCaw8fUNraVSf3Omoob1dO/AzBfhtFAPW0an6sBo= +github.com/go-openapi/testify/v2 v2.5.1/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw= github.com/go-openapi/validate v0.25.2 h1:12NsfLAwGegqbGWr2CnvT65X/Q2USJipmJ9b7xDJZz0= github.com/go-openapi/validate v0.25.2/go.mod h1:Pgl1LpPPGFnZ+ys4/hTlDiRYQdI1ocKypgE+8Q8BLfY= github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= diff --git a/go.work.sum b/go.work.sum index 93ee5414..96d5e14d 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1,4 +1,8 @@ cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-openapi/testify/v2 v2.5.1 h1:TMdhCaw8fUNraVSf3Omoob1dO/AzBfhtFAPW0an6sBo= +github.com/go-openapi/testify/v2 v2.5.1/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw= github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U= golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA= golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q= diff --git a/hack/tools/regen.go b/hack/tools/regen.go index 3d76dd37..d05a4b60 100644 --- a/hack/tools/regen.go +++ b/hack/tools/regen.go @@ -102,6 +102,14 @@ var steps = []regenStep{ {"swagger", "generate", "server", "-A", "TodoList", "-f", "./swagger.yml"}, }, }, + { + dir: "todo-list-errors", + preserve: []string{"restapi/configure_todo_list.go"}, + clean: []string{"cmd", "models", "restapi"}, + commands: [][]string{ + {"swagger", "generate", "server", "-A", "TodoList", "-f", "./swagger.yml", "-e"}, + }, + }, { dir: "tutorials/custom-server", clean: []string{"gen"}, diff --git a/oauth2/models/customer.go b/oauth2/models/customer.go index 79b0f1c8..381d0c79 100644 --- a/oauth2/models/customer.go +++ b/oauth2/models/customer.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -164,13 +164,13 @@ func (m *Customer) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Customer) UnmarshalBinary(b []byte) error { var res Customer - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/oauth2/models/error.go b/oauth2/models/error.go index 4102bd38..35003bc7 100644 --- a/oauth2/models/error.go +++ b/oauth2/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -60,13 +60,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/oauth2/models/social_id.go b/oauth2/models/social_id.go index df0a5d62..3e231b7e 100644 --- a/oauth2/models/social_id.go +++ b/oauth2/models/social_id.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -59,13 +59,13 @@ func (m *SocialID) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *SocialID) UnmarshalBinary(b []byte) error { var res SocialID - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/oauth2/restapi/configure_oauth_sample.go b/oauth2/restapi/configure_oauth_sample.go index ce1a78c4..5e41fc10 100644 --- a/oauth2/restapi/configure_oauth_sample.go +++ b/oauth2/restapi/configure_oauth_sample.go @@ -11,18 +11,17 @@ import ( errors "github.com/go-openapi/errors" runtime "github.com/go-openapi/runtime" middleware "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" + models "github.com/go-swagger/examples/oauth2/models" "github.com/go-swagger/examples/oauth2/restapi/operations" "github.com/go-swagger/examples/oauth2/restapi/operations/customers" - - models "github.com/go-swagger/examples/oauth2/models" ) //go:generate swagger generate server --target .. --name oauthSample --spec ../swagger.yml --principal models.Principal func configureFlags(api *operations.OauthSampleAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } @@ -66,7 +65,7 @@ func configureAPI(api *operations.OauthSampleAPI) http.Handler { return middleware.NotImplemented("operation .GetAuthCallback error") } log.Println("Token", token) - return operations.NewGetAuthCallbackDefault(500).WithPayload(&models.Error{Code: 500, Message: swag.String(token)}) + return operations.NewGetAuthCallbackDefault(500).WithPayload(&models.Error{Code: 500, Message: conv.Pointer(token)}) }) api.GetLoginHandler = operations.GetLoginHandlerFunc(func(params operations.GetLoginParams) middleware.Responder { return login(params.HTTPRequest) diff --git a/oauth2/restapi/implementation.go b/oauth2/restapi/implementation.go index a3b85fd7..034a20b2 100644 --- a/oauth2/restapi/implementation.go +++ b/oauth2/restapi/implementation.go @@ -19,17 +19,17 @@ import ( var ( // state carries an internal token during the oauth2 workflow - // we just need a non empty initial value + // we just need a non empty initial value. state = "foobar" // Don't make this a global in production. - // the credentials for this API (adapt values when registering API) + // the credentials for this API (adapt values when registering API). clientID = "" // <= enter registered API client ID here clientSecret = "" // <= enter registered API client secret here // unused in this example: the signer of the delivered token // issuer = "https://accounts.google.com" - // the Google login URL + // the Google login URL. authURL = "https://accounts.google.com/o/oauth2/v2/auth" // the Google OAuth2 resource provider which delivers access tokens @@ -37,10 +37,10 @@ var ( tokenURL = "https://www.googleapis.com/oauth2/v4/token" userInfoURL = "https://www.googleapis.com/oauth2/v3/userinfo" - // our endpoint to be called back by the redirected client + // our endpoint to be called back by the redirected client. callbackURL = "http://127.0.0.1:12345/api/auth/callback" - // the description of the OAuth2 flow + // the description of the OAuth2 flow. endpoint = oauth2.Endpoint{ AuthURL: authURL, TokenURL: tokenURL, @@ -98,8 +98,9 @@ func callback(r *http.Request) (string, error) { func authenticated(token string) (bool, error) { // validates the token by sending a request at userInfoURL + ctx := context.Background() bearToken := "Bearer " + token - req, err := http.NewRequest("GET", userInfoURL, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, userInfoURL, nil) if err != nil { return false, fmt.Errorf("http request: %w", err) } @@ -117,7 +118,7 @@ func authenticated(token string) (bool, error) { if err != nil { return false, fmt.Errorf("fail to get response: %w", err) } - if resp.StatusCode != 200 { + if resp.StatusCode != http.StatusOK { return false, nil } return true, nil diff --git a/oauth2/restapi/operations/customers/create_responses.go b/oauth2/restapi/operations/customers/create_responses.go index 055829ae..1832fac3 100644 --- a/oauth2/restapi/operations/customers/create_responses.go +++ b/oauth2/restapi/operations/customers/create_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/oauth2/models" ) diff --git a/oauth2/restapi/operations/customers/get_id_responses.go b/oauth2/restapi/operations/customers/get_id_responses.go index aeda19c7..681648e7 100644 --- a/oauth2/restapi/operations/customers/get_id_responses.go +++ b/oauth2/restapi/operations/customers/get_id_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/oauth2/models" ) diff --git a/oauth2/restapi/operations/get_auth_callback.go b/oauth2/restapi/operations/get_auth_callback.go index f2eb861b..46e02453 100644 --- a/oauth2/restapi/operations/get_auth_callback.go +++ b/oauth2/restapi/operations/get_auth_callback.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // GetAuthCallbackHandlerFunc turns a function with the right signature into a get auth callback handler @@ -80,13 +80,13 @@ func (o *GetAuthCallbackOKBody) MarshalBinary() ([]byte, error) { if o == nil { return nil, nil } - return swag.WriteJSON(o) + return jsonutils.WriteJSON(o) } // UnmarshalBinary interface implementation func (o *GetAuthCallbackOKBody) UnmarshalBinary(b []byte) error { var res GetAuthCallbackOKBody - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *o = res diff --git a/oauth2/restapi/operations/get_auth_callback_responses.go b/oauth2/restapi/operations/get_auth_callback_responses.go index 974f1f25..8fdd8be9 100644 --- a/oauth2/restapi/operations/get_auth_callback_responses.go +++ b/oauth2/restapi/operations/get_auth_callback_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/oauth2/models" ) diff --git a/oauth2/restapi/operations/get_login.go b/oauth2/restapi/operations/get_login.go index 0031d53f..13b95196 100644 --- a/oauth2/restapi/operations/get_login.go +++ b/oauth2/restapi/operations/get_login.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // GetLoginHandlerFunc turns a function with the right signature into a get login handler @@ -80,13 +80,13 @@ func (o *GetLoginOKBody) MarshalBinary() ([]byte, error) { if o == nil { return nil, nil } - return swag.WriteJSON(o) + return jsonutils.WriteJSON(o) } // UnmarshalBinary interface implementation func (o *GetLoginOKBody) UnmarshalBinary(b []byte) error { var res GetLoginOKBody - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *o = res diff --git a/oauth2/restapi/operations/get_login_responses.go b/oauth2/restapi/operations/get_login_responses.go index b92c85a9..6f52d414 100644 --- a/oauth2/restapi/operations/get_login_responses.go +++ b/oauth2/restapi/operations/get_login_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/oauth2/models" ) diff --git a/oauth2/restapi/operations/oauth_sample_api.go b/oauth2/restapi/operations/oauth_sample_api.go index eedc6376..d63ab740 100644 --- a/oauth2/restapi/operations/oauth_sample_api.go +++ b/oauth2/restapi/operations/oauth_sample_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/oauth2/models" "github.com/go-swagger/examples/oauth2/restapi/operations/customers" @@ -141,7 +141,7 @@ type OauthSampleAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/oauth2/restapi/server.go b/oauth2/restapi/server.go index a8374ca5..79b2d971 100644 --- a/oauth2/restapi/server.go +++ b/oauth2/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/oauth2/restapi/operations" ) @@ -368,7 +368,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -383,7 +383,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/resume b/resume new file mode 100644 index 00000000..9211898c --- /dev/null +++ b/resume @@ -0,0 +1 @@ +claude --resume 4cb0ad5c-656e-4870-9d4e-1d671989bc96 diff --git a/stream-client/client/jigsaw_client.go b/stream-client/client/jigsaw_client.go index fcb8af12..05a1bb98 100644 --- a/stream-client/client/jigsaw_client.go +++ b/stream-client/client/jigsaw_client.go @@ -6,7 +6,6 @@ import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/stream-client/client/operations" ) diff --git a/stream-server/biz/count.go b/stream-server/biz/count.go index 779d02bb..a87d40d7 100644 --- a/stream-server/biz/count.go +++ b/stream-server/biz/count.go @@ -10,10 +10,10 @@ import ( "github.com/go-swagger/examples/stream-server/models" ) -// MyCounter is the concrete implementation +// MyCounter is the concrete implementation. type MyCounter struct{} -// Down is the concrete implementation that spits out the JSON bodies +// Down is the concrete implementation that spits out the JSON bodies. func (mc *MyCounter) Down(maximum int64, w io.Writer) error { if maximum == 11 { return errors.New("we don't *do* elevensies") @@ -22,10 +22,14 @@ func (mc *MyCounter) Down(maximum int64, w io.Writer) error { for ix := int64(0); ix <= maximum; ix++ { r := maximum - ix fmt.Printf("Iteration %d\n", r) - _ = e.Encode(models.Mark{Remains: &r}) + if err := e.Encode(models.Mark{Remains: &r}); err != nil { + return err + } + if ix != maximum { time.Sleep(1 * time.Second) } } + return nil } diff --git a/stream-server/client/countdown_client.go b/stream-server/client/countdown_client.go index 1cadb5a0..ddae8714 100644 --- a/stream-server/client/countdown_client.go +++ b/stream-server/client/countdown_client.go @@ -6,7 +6,6 @@ import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/stream-server/client/operations" ) diff --git a/stream-server/client/operations/elapse_parameters.go b/stream-server/client/operations/elapse_parameters.go index ed3663d9..6e3addf6 100644 --- a/stream-server/client/operations/elapse_parameters.go +++ b/stream-server/client/operations/elapse_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewElapseParams creates a new ElapseParams object, @@ -138,7 +138,7 @@ func (o *ElapseParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regist var res []error // path param length - if err := r.SetPathParam("length", swag.FormatInt64(o.Length)); err != nil { + if err := r.SetPathParam("length", conv.FormatInteger(o.Length)); err != nil { return err } diff --git a/stream-server/elapsed_client.go b/stream-server/elapsed_client.go index 293b2369..a60b49f1 100644 --- a/stream-server/elapsed_client.go +++ b/stream-server/elapsed_client.go @@ -15,7 +15,7 @@ import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-swagger/examples/stream-server/client" "github.com/go-swagger/examples/stream-server/client/operations" "github.com/go-swagger/examples/stream-server/models" @@ -25,7 +25,7 @@ func main() { n := int64(5) if len(os.Args) > 1 { var err error - n, err = swag.ConvertInt64(os.Args[1]) + n, err = conv.ConvertInt64(os.Args[1]) if err != nil { log.Fatalln("pass an integer as argument") return @@ -72,7 +72,7 @@ func ask(n int64) error { return } - log.Printf("received countdown mark - remaining: %d", swag.Int64Value(mark.Remains)) + log.Printf("received countdown mark - remaining: %d", conv.Value(mark.Remains)) } if err := scanner.Err(); err != nil { diff --git a/stream-server/models/mark.go b/stream-server/models/mark.go index 23b635c1..4049a838 100644 --- a/stream-server/models/mark.go +++ b/stream-server/models/mark.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -54,13 +54,13 @@ func (m *Mark) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Mark) UnmarshalBinary(b []byte) error { var res Mark - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/stream-server/restapi/configure_countdown.go b/stream-server/restapi/configure_countdown.go index 50f094b2..ea407276 100644 --- a/stream-server/restapi/configure_countdown.go +++ b/stream-server/restapi/configure_countdown.go @@ -19,7 +19,7 @@ import ( //go:generate swagger generate server --target .. --name Countdown --spec ../swagger.yml func configureFlags(api *operations.CountdownAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } @@ -45,7 +45,7 @@ func configureAPI(api *operations.CountdownAPI) http.Handler { return middleware.ResponderFunc(func(rw http.ResponseWriter, _ runtime.Producer) { f, _ := rw.(http.Flusher) - rw.WriteHeader(200) + rw.WriteHeader(http.StatusOK) _ = myCounter.Down(params.Length, &flushWriter{f: f, w: rw}) }) }) diff --git a/stream-server/restapi/operations/countdown_api.go b/stream-server/restapi/operations/countdown_api.go index 345f69c5..3357b536 100644 --- a/stream-server/restapi/operations/countdown_api.go +++ b/stream-server/restapi/operations/countdown_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" ) // NewCountdownAPI creates a new Countdown instance @@ -96,7 +96,7 @@ type CountdownAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/stream-server/restapi/operations/elapse_parameters.go b/stream-server/restapi/operations/elapse_parameters.go index 19a304d6..000e496b 100644 --- a/stream-server/restapi/operations/elapse_parameters.go +++ b/stream-server/restapi/operations/elapse_parameters.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -66,7 +66,7 @@ func (o *ElapseParams) bindLength(rawData []string, hasKey bool, formats strfmt. // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("length", "path", "int64", raw) } diff --git a/stream-server/restapi/operations/elapse_urlbuilder.go b/stream-server/restapi/operations/elapse_urlbuilder.go index 8f74a725..7fbd86ff 100644 --- a/stream-server/restapi/operations/elapse_urlbuilder.go +++ b/stream-server/restapi/operations/elapse_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // ElapseURL generates an URL for the elapse operation @@ -41,7 +41,7 @@ func (o *ElapseURL) Build() (*url.URL, error) { var _path = "/elapse/{length}" - length := swag.FormatInt64(o.Length) + length := conv.FormatInteger(o.Length) if length != "" { _path = strings.ReplaceAll(_path, "{length}", length) } else { diff --git a/stream-server/restapi/server.go b/stream-server/restapi/server.go index d5400d3a..0bde8057 100644 --- a/stream-server/restapi/server.go +++ b/stream-server/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/stream-server/restapi/operations" ) @@ -368,7 +368,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -383,7 +383,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/task-tracker/client/task_tracker_client.go b/task-tracker/client/task_tracker_client.go index 8eb7ffa1..b49a9c8c 100644 --- a/task-tracker/client/task_tracker_client.go +++ b/task-tracker/client/task_tracker_client.go @@ -6,7 +6,6 @@ import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/task-tracker/client/tasks" ) diff --git a/task-tracker/client/tasks/add_comment_to_task_parameters.go b/task-tracker/client/tasks/add_comment_to_task_parameters.go index 596780be..a812b613 100644 --- a/task-tracker/client/tasks/add_comment_to_task_parameters.go +++ b/task-tracker/client/tasks/add_comment_to_task_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewAddCommentToTaskParams creates a new AddCommentToTaskParams object, @@ -160,7 +160,7 @@ func (o *AddCommentToTaskParams) WriteToRequest(r runtime.ClientRequest, reg str } // path param id - if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { + if err := r.SetPathParam("id", conv.FormatInteger(o.ID)); err != nil { return err } diff --git a/task-tracker/client/tasks/add_comment_to_task_responses.go b/task-tracker/client/tasks/add_comment_to_task_responses.go index ef5202d8..639bfa64 100644 --- a/task-tracker/client/tasks/add_comment_to_task_responses.go +++ b/task-tracker/client/tasks/add_comment_to_task_responses.go @@ -12,9 +12,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" - "github.com/go-swagger/examples/task-tracker/models" ) @@ -246,13 +245,13 @@ func (o *AddCommentToTaskBody) MarshalBinary() ([]byte, error) { if o == nil { return nil, nil } - return swag.WriteJSON(o) + return jsonutils.WriteJSON(o) } // UnmarshalBinary interface implementation func (o *AddCommentToTaskBody) UnmarshalBinary(b []byte) error { var res AddCommentToTaskBody - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *o = res diff --git a/task-tracker/client/tasks/create_task_parameters.go b/task-tracker/client/tasks/create_task_parameters.go index d848861c..b1fee8f4 100644 --- a/task-tracker/client/tasks/create_task_parameters.go +++ b/task-tracker/client/tasks/create_task_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/client/tasks/create_task_responses.go b/task-tracker/client/tasks/create_task_responses.go index 15280e24..804d1baa 100644 --- a/task-tracker/client/tasks/create_task_responses.go +++ b/task-tracker/client/tasks/create_task_responses.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/client/tasks/delete_task_parameters.go b/task-tracker/client/tasks/delete_task_parameters.go index 1f077816..cc729a97 100644 --- a/task-tracker/client/tasks/delete_task_parameters.go +++ b/task-tracker/client/tasks/delete_task_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewDeleteTaskParams creates a new DeleteTaskParams object, @@ -140,7 +140,7 @@ func (o *DeleteTaskParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Re var res []error // path param id - if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { + if err := r.SetPathParam("id", conv.FormatInteger(o.ID)); err != nil { return err } diff --git a/task-tracker/client/tasks/delete_task_responses.go b/task-tracker/client/tasks/delete_task_responses.go index 79121187..8fa49fd0 100644 --- a/task-tracker/client/tasks/delete_task_responses.go +++ b/task-tracker/client/tasks/delete_task_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/client/tasks/get_task_comments_parameters.go b/task-tracker/client/tasks/get_task_comments_parameters.go index bffd452f..a3950bf6 100644 --- a/task-tracker/client/tasks/get_task_comments_parameters.go +++ b/task-tracker/client/tasks/get_task_comments_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewGetTaskCommentsParams creates a new GetTaskCommentsParams object, @@ -190,7 +190,7 @@ func (o *GetTaskCommentsParams) WriteToRequest(r runtime.ClientRequest, reg strf var res []error // path param id - if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { + if err := r.SetPathParam("id", conv.FormatInteger(o.ID)); err != nil { return err } @@ -202,7 +202,7 @@ func (o *GetTaskCommentsParams) WriteToRequest(r runtime.ClientRequest, reg strf if o.PageSize != nil { qrPageSize = *o.PageSize } - qPageSize := swag.FormatInt32(qrPageSize) + qPageSize := conv.FormatInteger(qrPageSize) if qPageSize != "" { if err := r.SetQueryParam("pageSize", qPageSize); err != nil { diff --git a/task-tracker/client/tasks/get_task_comments_responses.go b/task-tracker/client/tasks/get_task_comments_responses.go index 8fd5eb8b..cd9500bd 100644 --- a/task-tracker/client/tasks/get_task_comments_responses.go +++ b/task-tracker/client/tasks/get_task_comments_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/client/tasks/get_task_details_parameters.go b/task-tracker/client/tasks/get_task_details_parameters.go index 181bb3e6..54cff2ca 100644 --- a/task-tracker/client/tasks/get_task_details_parameters.go +++ b/task-tracker/client/tasks/get_task_details_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewGetTaskDetailsParams creates a new GetTaskDetailsParams object, @@ -140,7 +140,7 @@ func (o *GetTaskDetailsParams) WriteToRequest(r runtime.ClientRequest, reg strfm var res []error // path param id - if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { + if err := r.SetPathParam("id", conv.FormatInteger(o.ID)); err != nil { return err } diff --git a/task-tracker/client/tasks/get_task_details_responses.go b/task-tracker/client/tasks/get_task_details_responses.go index 139f974d..f6671cbb 100644 --- a/task-tracker/client/tasks/get_task_details_responses.go +++ b/task-tracker/client/tasks/get_task_details_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/client/tasks/list_tasks_parameters.go b/task-tracker/client/tasks/list_tasks_parameters.go index 9ad1da31..a04749bb 100644 --- a/task-tracker/client/tasks/list_tasks_parameters.go +++ b/task-tracker/client/tasks/list_tasks_parameters.go @@ -11,7 +11,8 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" + "github.com/go-openapi/swag/stringutils" ) // NewListTasksParams creates a new ListTasksParams object, @@ -212,7 +213,7 @@ func (o *ListTasksParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg if o.PageSize != nil { qrPageSize = *o.PageSize } - qPageSize := swag.FormatInt32(qrPageSize) + qPageSize := conv.FormatInteger(qrPageSize) if qPageSize != "" { if err := r.SetQueryParam("pageSize", qPageSize); err != nil { @@ -229,7 +230,7 @@ func (o *ListTasksParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Reg if o.SinceID != nil { qrSinceID = *o.SinceID } - qSinceID := swag.FormatInt64(qrSinceID) + qSinceID := conv.FormatInteger(qrSinceID) if qSinceID != "" { if err := r.SetQueryParam("sinceId", qSinceID); err != nil { @@ -278,7 +279,7 @@ func (o *ListTasksParams) bindParamStatus(formats strfmt.Registry) []string { } // items.CollectionFormat: "pipes" - statusIS := swag.JoinByFormat(statusIC, "pipes") + statusIS := stringutils.JoinByFormat(statusIC, "pipes") return statusIS } @@ -295,7 +296,7 @@ func (o *ListTasksParams) bindParamTags(formats strfmt.Registry) []string { } // items.CollectionFormat: "" - tagsIS := swag.JoinByFormat(tagsIC, "") + tagsIS := stringutils.JoinByFormat(tagsIC, "") return tagsIS } diff --git a/task-tracker/client/tasks/list_tasks_responses.go b/task-tracker/client/tasks/list_tasks_responses.go index 8b521dee..5788ae56 100644 --- a/task-tracker/client/tasks/list_tasks_responses.go +++ b/task-tracker/client/tasks/list_tasks_responses.go @@ -11,8 +11,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - + "github.com/go-openapi/swag/conv" "github.com/go-swagger/examples/task-tracker/models" ) @@ -119,7 +118,7 @@ func (o *ListTasksOK) readResponse(response runtime.ClientResponse, consumer run hdrXLastTaskID := response.GetHeader("X-Last-Task-Id") if hdrXLastTaskID != "" { - valxLastTaskId, err := swag.ConvertInt64(hdrXLastTaskID) + valxLastTaskId, err := conv.ConvertInt64(hdrXLastTaskID) if err != nil { return errors.InvalidType("X-Last-Task-Id", "header", "int64", hdrXLastTaskID) } diff --git a/task-tracker/client/tasks/update_task_parameters.go b/task-tracker/client/tasks/update_task_parameters.go index c6742f7c..8bd8c021 100644 --- a/task-tracker/client/tasks/update_task_parameters.go +++ b/task-tracker/client/tasks/update_task_parameters.go @@ -11,8 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - + "github.com/go-openapi/swag/conv" "github.com/go-swagger/examples/task-tracker/models" ) @@ -164,7 +163,7 @@ func (o *UpdateTaskParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Re } // path param id - if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { + if err := r.SetPathParam("id", conv.FormatInteger(o.ID)); err != nil { return err } diff --git a/task-tracker/client/tasks/update_task_responses.go b/task-tracker/client/tasks/update_task_responses.go index fd32d1c3..002f068d 100644 --- a/task-tracker/client/tasks/update_task_responses.go +++ b/task-tracker/client/tasks/update_task_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/client/tasks/upload_task_file_parameters.go b/task-tracker/client/tasks/upload_task_file_parameters.go index a9ac6423..41bf9384 100644 --- a/task-tracker/client/tasks/upload_task_file_parameters.go +++ b/task-tracker/client/tasks/upload_task_file_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewUploadTaskFileParams creates a new UploadTaskFileParams object, @@ -199,7 +199,7 @@ func (o *UploadTaskFileParams) WriteToRequest(r runtime.ClientRequest, reg strfm } // path param id - if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil { + if err := r.SetPathParam("id", conv.FormatInteger(o.ID)); err != nil { return err } diff --git a/task-tracker/client/tasks/upload_task_file_responses.go b/task-tracker/client/tasks/upload_task_file_responses.go index 37d00d44..48582334 100644 --- a/task-tracker/client/tasks/upload_task_file_responses.go +++ b/task-tracker/client/tasks/upload_task_file_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/models/comment.go b/task-tracker/models/comment.go index d82bab3a..a6de8fbc 100644 --- a/task-tracker/models/comment.go +++ b/task-tracker/models/comment.go @@ -8,7 +8,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) @@ -70,7 +71,7 @@ func (m *Comment) validateContent(formats strfmt.Registry) error { } func (m *Comment) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required + if typeutils.IsZero(m.CreatedAt) { // not required return nil } @@ -158,13 +159,13 @@ func (m *Comment) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Comment) UnmarshalBinary(b []byte) error { var res Comment - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/task-tracker/models/error.go b/task-tracker/models/error.go index 79bf78f8..fc6aa80e 100644 --- a/task-tracker/models/error.go +++ b/task-tracker/models/error.go @@ -7,7 +7,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) @@ -64,7 +65,7 @@ func (m *Error) validateCode(formats strfmt.Registry) error { } func (m *Error) validateHelpURL(formats strfmt.Registry) error { - if swag.IsZero(m.HelpURL) { // not required + if typeutils.IsZero(m.HelpURL) { // not required return nil } @@ -94,13 +95,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/task-tracker/models/milestone.go b/task-tracker/models/milestone.go index 5fe99dea..fe3ddb6c 100644 --- a/task-tracker/models/milestone.go +++ b/task-tracker/models/milestone.go @@ -8,7 +8,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) @@ -70,7 +71,7 @@ func (m *Milestone) Validate(formats strfmt.Registry) error { } func (m *Milestone) validateDueDate(formats strfmt.Registry) error { - if swag.IsZero(m.DueDate) { // not required + if typeutils.IsZero(m.DueDate) { // not required return nil } @@ -103,7 +104,7 @@ func (m *Milestone) validateName(formats strfmt.Registry) error { } func (m *Milestone) validateStats(formats strfmt.Registry) error { - if swag.IsZero(m.Stats) { // not required + if typeutils.IsZero(m.Stats) { // not required return nil } @@ -143,7 +144,7 @@ func (m *Milestone) contextValidateStats(ctx context.Context, formats strfmt.Reg if m.Stats != nil { - if swag.IsZero(m.Stats) { // not required + if typeutils.IsZero(m.Stats) { // not required return nil } @@ -169,13 +170,13 @@ func (m *Milestone) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Milestone) UnmarshalBinary(b []byte) error { var res Milestone - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res @@ -214,13 +215,13 @@ func (m *MilestoneStats) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *MilestoneStats) UnmarshalBinary(b []byte) error { var res MilestoneStats - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/task-tracker/models/task.go b/task-tracker/models/task.go index 36dea03b..efae70ab 100644 --- a/task-tracker/models/task.go +++ b/task-tracker/models/task.go @@ -10,7 +10,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) @@ -55,7 +56,7 @@ type Task struct { func (m *Task) UnmarshalJSON(raw []byte) error { // AO0 var aO0 TaskCard - if err := swag.ReadJSON(raw, &aO0); err != nil { + if err := jsonutils.ReadJSON(raw, &aO0); err != nil { return err } m.TaskCard = aO0 @@ -72,7 +73,7 @@ func (m *Task) UnmarshalJSON(raw []byte) error { ReportedBy *UserCard `json:"reportedBy,omitempty"` } - if err := swag.ReadJSON(raw, &dataAO1); err != nil { + if err := jsonutils.ReadJSON(raw, &dataAO1); err != nil { return err } @@ -93,7 +94,7 @@ func (m *Task) UnmarshalJSON(raw []byte) error { func (m Task) MarshalJSON() ([]byte, error) { _parts := make([][]byte, 0, 2) - aO0, err := swag.WriteJSON(m.TaskCard) + aO0, err := jsonutils.WriteJSON(m.TaskCard) if err != nil { return nil, err } @@ -120,12 +121,12 @@ func (m Task) MarshalJSON() ([]byte, error) { dataAO1.ReportedBy = m.ReportedBy - jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1) + jsonDataAO1, errAO1 := jsonutils.WriteJSON(dataAO1) if errAO1 != nil { return nil, errAO1 } _parts = append(_parts, jsonDataAO1) - return swag.ConcatJSON(_parts...), nil + return jsonutils.ConcatJSON(_parts...), nil } // Validate validates this task @@ -165,13 +166,13 @@ func (m *Task) Validate(formats strfmt.Registry) error { func (m *Task) validateAttachments(formats strfmt.Registry) error { - if swag.IsZero(m.Attachments) { // not required + if typeutils.IsZero(m.Attachments) { // not required return nil } for k := range m.Attachments { - if swag.IsZero(m.Attachments[k]) { // not required + if typeutils.IsZero(m.Attachments[k]) { // not required continue } if val, ok := m.Attachments[k]; ok { @@ -196,12 +197,12 @@ func (m *Task) validateAttachments(formats strfmt.Registry) error { func (m *Task) validateComments(formats strfmt.Registry) error { - if swag.IsZero(m.Comments) { // not required + if typeutils.IsZero(m.Comments) { // not required return nil } for i := 0; i < len(m.Comments); i++ { - if swag.IsZero(m.Comments[i]) { // not required + if typeutils.IsZero(m.Comments[i]) { // not required continue } @@ -227,7 +228,7 @@ func (m *Task) validateComments(formats strfmt.Registry) error { func (m *Task) validateLastUpdated(formats strfmt.Registry) error { - if swag.IsZero(m.LastUpdated) { // not required + if typeutils.IsZero(m.LastUpdated) { // not required return nil } @@ -240,7 +241,7 @@ func (m *Task) validateLastUpdated(formats strfmt.Registry) error { func (m *Task) validateLastUpdatedBy(formats strfmt.Registry) error { - if swag.IsZero(m.LastUpdatedBy) { // not required + if typeutils.IsZero(m.LastUpdatedBy) { // not required return nil } @@ -264,7 +265,7 @@ func (m *Task) validateLastUpdatedBy(formats strfmt.Registry) error { func (m *Task) validateReportedBy(formats strfmt.Registry) error { - if swag.IsZero(m.ReportedBy) { // not required + if typeutils.IsZero(m.ReportedBy) { // not required return nil } @@ -346,7 +347,7 @@ func (m *Task) contextValidateComments(ctx context.Context, formats strfmt.Regis if m.Comments[i] != nil { - if swag.IsZero(m.Comments[i]) { // not required + if typeutils.IsZero(m.Comments[i]) { // not required return nil } @@ -382,7 +383,7 @@ func (m *Task) contextValidateLastUpdatedBy(ctx context.Context, formats strfmt. if m.LastUpdatedBy != nil { - if swag.IsZero(m.LastUpdatedBy) { // not required + if typeutils.IsZero(m.LastUpdatedBy) { // not required return nil } @@ -407,7 +408,7 @@ func (m *Task) contextValidateReportedBy(ctx context.Context, formats strfmt.Reg if m.ReportedBy != nil { - if swag.IsZero(m.ReportedBy) { // not required + if typeutils.IsZero(m.ReportedBy) { // not required return nil } @@ -433,13 +434,13 @@ func (m *Task) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Task) UnmarshalBinary(b []byte) error { var res Task - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res @@ -638,7 +639,7 @@ func (m TaskAttachmentsAnon) MarshalJSON() ([]byte, error) { } // concatenate the 2 objects - return swag.ConcatJSON(props, additional), nil + return jsonutils.ConcatJSON(props, additional), nil } // Validate validates this task attachments anon @@ -646,12 +647,12 @@ func (m *TaskAttachmentsAnon) Validate(formats strfmt.Registry) error { var res []error props := make(map[string]json.RawMessage, 5+10) - j, err := swag.WriteJSON(m) + j, err := jsonutils.WriteJSON(m) if err != nil { return err } - if err = swag.ReadJSON(j, &props); err != nil { + if err = jsonutils.ReadJSON(j, &props); err != nil { return err } @@ -677,7 +678,7 @@ func (m *TaskAttachmentsAnon) Validate(formats strfmt.Registry) error { } func (m *TaskAttachmentsAnon) validateDescription(formats strfmt.Registry) error { - if swag.IsZero(m.Description) { // not required + if typeutils.IsZero(m.Description) { // not required return nil } @@ -689,7 +690,7 @@ func (m *TaskAttachmentsAnon) validateDescription(formats strfmt.Registry) error } func (m *TaskAttachmentsAnon) validateURL(formats strfmt.Registry) error { - if swag.IsZero(m.URL) { // not required + if typeutils.IsZero(m.URL) { // not required return nil } @@ -767,13 +768,13 @@ func (m *TaskAttachmentsAnon) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *TaskAttachmentsAnon) UnmarshalBinary(b []byte) error { var res TaskAttachmentsAnon - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/task-tracker/models/task_card.go b/task-tracker/models/task_card.go index 154dd477..9705c8a5 100644 --- a/task-tracker/models/task_card.go +++ b/task-tracker/models/task_card.go @@ -10,7 +10,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) @@ -141,7 +142,7 @@ func (m *TaskCard) Validate(formats strfmt.Registry) error { } func (m *TaskCard) validateAssignedTo(formats strfmt.Registry) error { - if swag.IsZero(m.AssignedTo) { // not required + if typeutils.IsZero(m.AssignedTo) { // not required return nil } @@ -164,7 +165,7 @@ func (m *TaskCard) validateAssignedTo(formats strfmt.Registry) error { } func (m *TaskCard) validateEffort(formats strfmt.Registry) error { - if swag.IsZero(m.Effort) { // not required + if typeutils.IsZero(m.Effort) { // not required return nil } @@ -180,7 +181,7 @@ func (m *TaskCard) validateEffort(formats strfmt.Registry) error { } func (m *TaskCard) validateKarma(formats strfmt.Registry) error { - if swag.IsZero(m.Karma) { // not required + if typeutils.IsZero(m.Karma) { // not required return nil } @@ -196,7 +197,7 @@ func (m *TaskCard) validateKarma(formats strfmt.Registry) error { } func (m *TaskCard) validateMilestone(formats strfmt.Registry) error { - if swag.IsZero(m.Milestone) { // not required + if typeutils.IsZero(m.Milestone) { // not required return nil } @@ -219,7 +220,7 @@ func (m *TaskCard) validateMilestone(formats strfmt.Registry) error { } func (m *TaskCard) validateReportedAt(formats strfmt.Registry) error { - if swag.IsZero(m.ReportedAt) { // not required + if typeutils.IsZero(m.ReportedAt) { // not required return nil } @@ -231,7 +232,7 @@ func (m *TaskCard) validateReportedAt(formats strfmt.Registry) error { } func (m *TaskCard) validateSeverity(formats strfmt.Registry) error { - if swag.IsZero(m.Severity) { // not required + if typeutils.IsZero(m.Severity) { // not required return nil } @@ -296,7 +297,7 @@ func (m *TaskCard) validateStatus(formats strfmt.Registry) error { } func (m *TaskCard) validateTags(formats strfmt.Registry) error { - if swag.IsZero(m.Tags) { // not required + if typeutils.IsZero(m.Tags) { // not required return nil } @@ -372,7 +373,7 @@ func (m *TaskCard) contextValidateAssignedTo(ctx context.Context, formats strfmt if m.AssignedTo != nil { - if swag.IsZero(m.AssignedTo) { // not required + if typeutils.IsZero(m.AssignedTo) { // not required return nil } @@ -406,7 +407,7 @@ func (m *TaskCard) contextValidateMilestone(ctx context.Context, formats strfmt. if m.Milestone != nil { - if swag.IsZero(m.Milestone) { // not required + if typeutils.IsZero(m.Milestone) { // not required return nil } @@ -441,13 +442,13 @@ func (m *TaskCard) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *TaskCard) UnmarshalBinary(b []byte) error { var res TaskCard - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/task-tracker/models/user_card.go b/task-tracker/models/user_card.go index 7cac4395..86543e2a 100644 --- a/task-tracker/models/user_card.go +++ b/task-tracker/models/user_card.go @@ -7,7 +7,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" + "github.com/go-openapi/swag/typeutils" "github.com/go-openapi/validate" ) @@ -80,7 +81,7 @@ func (m *UserCard) Validate(formats strfmt.Registry) error { } func (m *UserCard) validateAvailableKarma(formats strfmt.Registry) error { - if swag.IsZero(m.AvailableKarma) { // not required + if typeutils.IsZero(m.AvailableKarma) { // not required return nil } @@ -175,13 +176,13 @@ func (m *UserCard) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *UserCard) UnmarshalBinary(b []byte) error { var res UserCard - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/task-tracker/models/validation_error.go b/task-tracker/models/validation_error.go index 2f5e3e29..b1cab318 100644 --- a/task-tracker/models/validation_error.go +++ b/task-tracker/models/validation_error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" ) // ValidationError validation error @@ -24,7 +24,7 @@ type ValidationError struct { func (m *ValidationError) UnmarshalJSON(raw []byte) error { // AO0 var aO0 Error - if err := swag.ReadJSON(raw, &aO0); err != nil { + if err := jsonutils.ReadJSON(raw, &aO0); err != nil { return err } m.Error = aO0 @@ -33,7 +33,7 @@ func (m *ValidationError) UnmarshalJSON(raw []byte) error { var dataAO1 struct { Field string `json:"field,omitempty"` } - if err := swag.ReadJSON(raw, &dataAO1); err != nil { + if err := jsonutils.ReadJSON(raw, &dataAO1); err != nil { return err } @@ -46,7 +46,7 @@ func (m *ValidationError) UnmarshalJSON(raw []byte) error { func (m ValidationError) MarshalJSON() ([]byte, error) { _parts := make([][]byte, 0, 2) - aO0, err := swag.WriteJSON(m.Error) + aO0, err := jsonutils.WriteJSON(m.Error) if err != nil { return nil, err } @@ -57,12 +57,12 @@ func (m ValidationError) MarshalJSON() ([]byte, error) { dataAO1.Field = m.Field - jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1) + jsonDataAO1, errAO1 := jsonutils.WriteJSON(dataAO1) if errAO1 != nil { return nil, errAO1 } _parts = append(_parts, jsonDataAO1) - return swag.ConcatJSON(_parts...), nil + return jsonutils.ConcatJSON(_parts...), nil } // Validate validates this validation error @@ -100,13 +100,13 @@ func (m *ValidationError) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *ValidationError) UnmarshalBinary(b []byte) error { var res ValidationError - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/task-tracker/restapi/configure_task_tracker.go b/task-tracker/restapi/configure_task_tracker.go index 452f9814..e226bc5c 100644 --- a/task-tracker/restapi/configure_task_tracker.go +++ b/task-tracker/restapi/configure_task_tracker.go @@ -17,7 +17,7 @@ import ( //go:generate swagger generate server --target ../../task-tracker --name TaskTracker --spec ../swagger.yml --principal any func configureFlags(api *operations.TaskTrackerAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/task-tracker/restapi/operations/task_tracker_api.go b/task-tracker/restapi/operations/task_tracker_api.go index ccf2b56c..7ace1cc4 100644 --- a/task-tracker/restapi/operations/task_tracker_api.go +++ b/task-tracker/restapi/operations/task_tracker_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/task-tracker/restapi/operations/tasks" ) @@ -196,7 +196,7 @@ type TaskTrackerAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/task-tracker/restapi/operations/tasks/add_comment_to_task.go b/task-tracker/restapi/operations/tasks/add_comment_to_task.go index 32a716c0..90669660 100644 --- a/task-tracker/restapi/operations/tasks/add_comment_to_task.go +++ b/task-tracker/restapi/operations/tasks/add_comment_to_task.go @@ -9,7 +9,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -136,13 +136,13 @@ func (o *AddCommentToTaskBody) MarshalBinary() ([]byte, error) { if o == nil { return nil, nil } - return swag.WriteJSON(o) + return jsonutils.WriteJSON(o) } // UnmarshalBinary interface implementation func (o *AddCommentToTaskBody) UnmarshalBinary(b []byte) error { var res AddCommentToTaskBody - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *o = res diff --git a/task-tracker/restapi/operations/tasks/add_comment_to_task_parameters.go b/task-tracker/restapi/operations/tasks/add_comment_to_task_parameters.go index 889a2b1f..979efb89 100644 --- a/task-tracker/restapi/operations/tasks/add_comment_to_task_parameters.go +++ b/task-tracker/restapi/operations/tasks/add_comment_to_task_parameters.go @@ -9,7 +9,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -94,7 +94,7 @@ func (o *AddCommentToTaskParams) bindID(rawData []string, hasKey bool, formats s // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("id", "path", "int64", raw) } diff --git a/task-tracker/restapi/operations/tasks/add_comment_to_task_responses.go b/task-tracker/restapi/operations/tasks/add_comment_to_task_responses.go index dd28e810..39549cea 100644 --- a/task-tracker/restapi/operations/tasks/add_comment_to_task_responses.go +++ b/task-tracker/restapi/operations/tasks/add_comment_to_task_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/restapi/operations/tasks/add_comment_to_task_urlbuilder.go b/task-tracker/restapi/operations/tasks/add_comment_to_task_urlbuilder.go index 5db5c5b4..2f300804 100644 --- a/task-tracker/restapi/operations/tasks/add_comment_to_task_urlbuilder.go +++ b/task-tracker/restapi/operations/tasks/add_comment_to_task_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // AddCommentToTaskURL generates an URL for the add comment to task operation @@ -41,7 +41,7 @@ func (o *AddCommentToTaskURL) Build() (*url.URL, error) { var _path = "/tasks/{id}/comments" - id := swag.FormatInt64(o.ID) + id := conv.FormatInteger(o.ID) if id != "" { _path = strings.ReplaceAll(_path, "{id}", id) } else { diff --git a/task-tracker/restapi/operations/tasks/create_task_responses.go b/task-tracker/restapi/operations/tasks/create_task_responses.go index 5fcb1ae0..59e564d2 100644 --- a/task-tracker/restapi/operations/tasks/create_task_responses.go +++ b/task-tracker/restapi/operations/tasks/create_task_responses.go @@ -7,7 +7,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/restapi/operations/tasks/delete_task_parameters.go b/task-tracker/restapi/operations/tasks/delete_task_parameters.go index 85cc9444..afc9e885 100644 --- a/task-tracker/restapi/operations/tasks/delete_task_parameters.go +++ b/task-tracker/restapi/operations/tasks/delete_task_parameters.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewDeleteTaskParams creates a new DeleteTaskParams object @@ -63,7 +63,7 @@ func (o *DeleteTaskParams) bindID(rawData []string, hasKey bool, formats strfmt. // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("id", "path", "int64", raw) } diff --git a/task-tracker/restapi/operations/tasks/delete_task_responses.go b/task-tracker/restapi/operations/tasks/delete_task_responses.go index 388e4cfe..239c3d2c 100644 --- a/task-tracker/restapi/operations/tasks/delete_task_responses.go +++ b/task-tracker/restapi/operations/tasks/delete_task_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/restapi/operations/tasks/delete_task_urlbuilder.go b/task-tracker/restapi/operations/tasks/delete_task_urlbuilder.go index c2bd6b33..e372408e 100644 --- a/task-tracker/restapi/operations/tasks/delete_task_urlbuilder.go +++ b/task-tracker/restapi/operations/tasks/delete_task_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // DeleteTaskURL generates an URL for the delete task operation @@ -41,7 +41,7 @@ func (o *DeleteTaskURL) Build() (*url.URL, error) { var _path = "/tasks/{id}" - id := swag.FormatInt64(o.ID) + id := conv.FormatInteger(o.ID) if id != "" { _path = strings.ReplaceAll(_path, "{id}", id) } else { diff --git a/task-tracker/restapi/operations/tasks/get_task_comments_parameters.go b/task-tracker/restapi/operations/tasks/get_task_comments_parameters.go index ac68a85d..5e373161 100644 --- a/task-tracker/restapi/operations/tasks/get_task_comments_parameters.go +++ b/task-tracker/restapi/operations/tasks/get_task_comments_parameters.go @@ -9,7 +9,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -94,7 +94,7 @@ func (o *GetTaskCommentsParams) bindID(rawData []string, hasKey bool, formats st // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("id", "path", "int64", raw) } @@ -118,7 +118,7 @@ func (o *GetTaskCommentsParams) bindPageSize(rawData []string, hasKey bool, form return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("pageSize", "query", "int32", raw) } diff --git a/task-tracker/restapi/operations/tasks/get_task_comments_responses.go b/task-tracker/restapi/operations/tasks/get_task_comments_responses.go index 96462ce6..b77e69af 100644 --- a/task-tracker/restapi/operations/tasks/get_task_comments_responses.go +++ b/task-tracker/restapi/operations/tasks/get_task_comments_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/restapi/operations/tasks/get_task_comments_urlbuilder.go b/task-tracker/restapi/operations/tasks/get_task_comments_urlbuilder.go index 4568fe0c..9179310a 100644 --- a/task-tracker/restapi/operations/tasks/get_task_comments_urlbuilder.go +++ b/task-tracker/restapi/operations/tasks/get_task_comments_urlbuilder.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // GetTaskCommentsURL generates an URL for the get task comments operation @@ -45,7 +45,7 @@ func (o *GetTaskCommentsURL) Build() (*url.URL, error) { var _path = "/tasks/{id}/comments" - id := swag.FormatInt64(o.ID) + id := conv.FormatInteger(o.ID) if id != "" { _path = strings.ReplaceAll(_path, "{id}", id) } else { @@ -62,7 +62,7 @@ func (o *GetTaskCommentsURL) Build() (*url.URL, error) { var pageSizeQ string if o.PageSize != nil { - pageSizeQ = swag.FormatInt32(*o.PageSize) + pageSizeQ = conv.FormatInteger(*o.PageSize) } if pageSizeQ != "" { qs.Set("pageSize", pageSizeQ) diff --git a/task-tracker/restapi/operations/tasks/get_task_details_parameters.go b/task-tracker/restapi/operations/tasks/get_task_details_parameters.go index fed3133c..7610471e 100644 --- a/task-tracker/restapi/operations/tasks/get_task_details_parameters.go +++ b/task-tracker/restapi/operations/tasks/get_task_details_parameters.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewGetTaskDetailsParams creates a new GetTaskDetailsParams object @@ -63,7 +63,7 @@ func (o *GetTaskDetailsParams) bindID(rawData []string, hasKey bool, formats str // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("id", "path", "int64", raw) } diff --git a/task-tracker/restapi/operations/tasks/get_task_details_responses.go b/task-tracker/restapi/operations/tasks/get_task_details_responses.go index e518d1ae..bc813edb 100644 --- a/task-tracker/restapi/operations/tasks/get_task_details_responses.go +++ b/task-tracker/restapi/operations/tasks/get_task_details_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/restapi/operations/tasks/get_task_details_urlbuilder.go b/task-tracker/restapi/operations/tasks/get_task_details_urlbuilder.go index 31f22201..63f667c1 100644 --- a/task-tracker/restapi/operations/tasks/get_task_details_urlbuilder.go +++ b/task-tracker/restapi/operations/tasks/get_task_details_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // GetTaskDetailsURL generates an URL for the get task details operation @@ -41,7 +41,7 @@ func (o *GetTaskDetailsURL) Build() (*url.URL, error) { var _path = "/tasks/{id}" - id := swag.FormatInt64(o.ID) + id := conv.FormatInteger(o.ID) if id != "" { _path = strings.ReplaceAll(_path, "{id}", id) } else { diff --git a/task-tracker/restapi/operations/tasks/list_tasks_parameters.go b/task-tracker/restapi/operations/tasks/list_tasks_parameters.go index 5a0a368d..ff5cbcd3 100644 --- a/task-tracker/restapi/operations/tasks/list_tasks_parameters.go +++ b/task-tracker/restapi/operations/tasks/list_tasks_parameters.go @@ -10,7 +10,8 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" + "github.com/go-openapi/swag/stringutils" "github.com/go-openapi/validate" ) @@ -112,7 +113,7 @@ func (o *ListTasksParams) bindPageSize(rawData []string, hasKey bool, formats st return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("pageSize", "query", "int32", raw) } @@ -135,7 +136,7 @@ func (o *ListTasksParams) bindSinceID(rawData []string, hasKey bool, formats str return nil } - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("sinceId", "query", "int64", raw) } @@ -154,7 +155,7 @@ func (o *ListTasksParams) bindStatus(rawData []string, hasKey bool, formats strf } // CollectionFormat: pipes - statusIC := swag.SplitByFormat(qvStatus, "pipes") + statusIC := stringutils.SplitByFormat(qvStatus, "pipes") if len(statusIC) == 0 { return nil } @@ -198,7 +199,7 @@ func (o *ListTasksParams) bindTags(rawData []string, hasKey bool, formats strfmt } // CollectionFormat: - tagsIC := swag.SplitByFormat(qvTags, "") + tagsIC := stringutils.SplitByFormat(qvTags, "") if len(tagsIC) == 0 { return nil } diff --git a/task-tracker/restapi/operations/tasks/list_tasks_responses.go b/task-tracker/restapi/operations/tasks/list_tasks_responses.go index 371ed28e..0aa6b1dc 100644 --- a/task-tracker/restapi/operations/tasks/list_tasks_responses.go +++ b/task-tracker/restapi/operations/tasks/list_tasks_responses.go @@ -6,8 +6,7 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-openapi/swag" - + "github.com/go-openapi/swag/conv" "github.com/go-swagger/examples/task-tracker/models" ) @@ -64,7 +63,7 @@ func (o *ListTasksOK) WriteResponse(rw http.ResponseWriter, producer runtime.Pro // response header X-Last-Task-Id - xLastTaskID := swag.FormatInt64(o.XLastTaskID) + xLastTaskID := conv.FormatInteger(o.XLastTaskID) if xLastTaskID != "" { rw.Header().Set("X-Last-Task-Id", xLastTaskID) } diff --git a/task-tracker/restapi/operations/tasks/list_tasks_urlbuilder.go b/task-tracker/restapi/operations/tasks/list_tasks_urlbuilder.go index 1761dbff..c17db286 100644 --- a/task-tracker/restapi/operations/tasks/list_tasks_urlbuilder.go +++ b/task-tracker/restapi/operations/tasks/list_tasks_urlbuilder.go @@ -7,7 +7,8 @@ import ( "net/url" golangswaggerpaths "path" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" + "github.com/go-openapi/swag/stringutils" ) // ListTasksURL generates an URL for the list tasks operation @@ -53,7 +54,7 @@ func (o *ListTasksURL) Build() (*url.URL, error) { var pageSizeQ string if o.PageSize != nil { - pageSizeQ = swag.FormatInt32(*o.PageSize) + pageSizeQ = conv.FormatInteger(*o.PageSize) } if pageSizeQ != "" { qs.Set("pageSize", pageSizeQ) @@ -61,7 +62,7 @@ func (o *ListTasksURL) Build() (*url.URL, error) { var sinceIDQ string if o.SinceID != nil { - sinceIDQ = swag.FormatInt64(*o.SinceID) + sinceIDQ = conv.FormatInteger(*o.SinceID) } if sinceIDQ != "" { qs.Set("sinceId", sinceIDQ) @@ -75,7 +76,7 @@ func (o *ListTasksURL) Build() (*url.URL, error) { } } - status := swag.JoinByFormat(statusIR, "pipes") + status := stringutils.JoinByFormat(statusIR, "pipes") if len(status) > 0 { qsv := status[0] @@ -92,7 +93,7 @@ func (o *ListTasksURL) Build() (*url.URL, error) { } } - tags := swag.JoinByFormat(tagsIR, "") + tags := stringutils.JoinByFormat(tagsIR, "") if len(tags) > 0 { qsv := tags[0] diff --git a/task-tracker/restapi/operations/tasks/update_task_parameters.go b/task-tracker/restapi/operations/tasks/update_task_parameters.go index 239aba54..d31a5660 100644 --- a/task-tracker/restapi/operations/tasks/update_task_parameters.go +++ b/task-tracker/restapi/operations/tasks/update_task_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" "github.com/go-swagger/examples/task-tracker/models" @@ -105,7 +105,7 @@ func (o *UpdateTaskParams) bindID(rawData []string, hasKey bool, formats strfmt. // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("id", "path", "int64", raw) } diff --git a/task-tracker/restapi/operations/tasks/update_task_responses.go b/task-tracker/restapi/operations/tasks/update_task_responses.go index ed16c9bd..9aad70b7 100644 --- a/task-tracker/restapi/operations/tasks/update_task_responses.go +++ b/task-tracker/restapi/operations/tasks/update_task_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/restapi/operations/tasks/update_task_urlbuilder.go b/task-tracker/restapi/operations/tasks/update_task_urlbuilder.go index 08f77451..4687f2cc 100644 --- a/task-tracker/restapi/operations/tasks/update_task_urlbuilder.go +++ b/task-tracker/restapi/operations/tasks/update_task_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // UpdateTaskURL generates an URL for the update task operation @@ -41,7 +41,7 @@ func (o *UpdateTaskURL) Build() (*url.URL, error) { var _path = "/tasks/{id}" - id := swag.FormatInt64(o.ID) + id := conv.FormatInteger(o.ID) if id != "" { _path = strings.ReplaceAll(_path, "{id}", id) } else { diff --git a/task-tracker/restapi/operations/tasks/upload_task_file_parameters.go b/task-tracker/restapi/operations/tasks/upload_task_file_parameters.go index f4e46f0a..998f0b28 100644 --- a/task-tracker/restapi/operations/tasks/upload_task_file_parameters.go +++ b/task-tracker/restapi/operations/tasks/upload_task_file_parameters.go @@ -12,7 +12,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // UploadTaskFileMaxParseMemory sets the maximum size in bytes for @@ -136,7 +136,7 @@ func (o *UploadTaskFileParams) bindID(rawData []string, hasKey bool, formats str // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("id", "path", "int64", raw) } diff --git a/task-tracker/restapi/operations/tasks/upload_task_file_responses.go b/task-tracker/restapi/operations/tasks/upload_task_file_responses.go index cba927b7..50bf8cc3 100644 --- a/task-tracker/restapi/operations/tasks/upload_task_file_responses.go +++ b/task-tracker/restapi/operations/tasks/upload_task_file_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/task-tracker/models" ) diff --git a/task-tracker/restapi/operations/tasks/upload_task_file_urlbuilder.go b/task-tracker/restapi/operations/tasks/upload_task_file_urlbuilder.go index 5599b2e4..9973d17d 100644 --- a/task-tracker/restapi/operations/tasks/upload_task_file_urlbuilder.go +++ b/task-tracker/restapi/operations/tasks/upload_task_file_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // UploadTaskFileURL generates an URL for the upload task file operation @@ -41,7 +41,7 @@ func (o *UploadTaskFileURL) Build() (*url.URL, error) { var _path = "/tasks/{id}/files" - id := swag.FormatInt64(o.ID) + id := conv.FormatInteger(o.ID) if id != "" { _path = strings.ReplaceAll(_path, "{id}", id) } else { diff --git a/task-tracker/restapi/server.go b/task-tracker/restapi/server.go index 785a2c2d..a36a6249 100644 --- a/task-tracker/restapi/server.go +++ b/task-tracker/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/task-tracker/restapi/operations" ) @@ -369,7 +369,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -384,7 +384,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/todo-list-errors/cmd/todo-list-server/main.go b/todo-list-errors/cmd/todo-list-server/main.go index 3c214902..0f9d746d 100644 --- a/todo-list-errors/cmd/todo-list-server/main.go +++ b/todo-list-errors/cmd/todo-list-server/main.go @@ -15,9 +15,6 @@ import ( "github.com/go-swagger/examples/todo-list-errors/restapi/operations" ) -// This file was generated by the swagger tool. -// Make sure not to overwrite this file after you generated it because all your edits would be lost! - func main() { swaggerSpec, err := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON) if err != nil { diff --git a/todo-list-errors/models/error.go b/todo-list-errors/models/error.go index c8de71b6..bac28f38 100644 --- a/todo-list-errors/models/error.go +++ b/todo-list-errors/models/error.go @@ -2,15 +2,12 @@ package models -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - import ( "context" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -60,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/todo-list-errors/models/item.go b/todo-list-errors/models/item.go index 9dad0aba..2e163a96 100644 --- a/todo-list-errors/models/item.go +++ b/todo-list-errors/models/item.go @@ -2,15 +2,12 @@ package models -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - import ( "context" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -87,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/todo-list-errors/restapi/configure_todo_list.go b/todo-list-errors/restapi/configure_todo_list.go index e6519fd1..b9afa990 100644 --- a/todo-list-errors/restapi/configure_todo_list.go +++ b/todo-list-errors/restapi/configure_todo_list.go @@ -19,7 +19,7 @@ import ( //go:generate swagger generate server --target ../../todo-list-errors --name TodoList --spec ../swagger.yml --principal any --return-errors func configureFlags(api *operations.TodoListAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } @@ -56,6 +56,8 @@ func configureAPI(api *operations.TodoListAPI) http.Handler { api.TodosAddOneHandler = todos.AddOneHandlerFunc( func(params todos.AddOneParams) (middleware.Responder, error) { + _ = params + return nil, errAlreadyExists }) diff --git a/todo-list-errors/restapi/embedded_spec.go b/todo-list-errors/restapi/embedded_spec.go index 51703ef0..480346e0 100644 --- a/todo-list-errors/restapi/embedded_spec.go +++ b/todo-list-errors/restapi/embedded_spec.go @@ -2,9 +2,6 @@ package restapi -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - import ( "encoding/json" ) diff --git a/todo-list-errors/restapi/operations/todo_list_api.go b/todo-list-errors/restapi/operations/todo_list_api.go index 7bbfd5b9..0d31b6fb 100644 --- a/todo-list-errors/restapi/operations/todo_list_api.go +++ b/todo-list-errors/restapi/operations/todo_list_api.go @@ -2,9 +2,6 @@ package operations -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - import ( "fmt" "net/http" @@ -17,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/todo-list-errors/restapi/operations/todos" ) @@ -129,7 +126,7 @@ type TodoListAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/todo-list-errors/restapi/operations/todos/add_one.go b/todo-list-errors/restapi/operations/todos/add_one.go index 2c3f77c3..da49f9c1 100644 --- a/todo-list-errors/restapi/operations/todos/add_one.go +++ b/todo-list-errors/restapi/operations/todos/add_one.go @@ -2,9 +2,6 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - import ( "net/http" diff --git a/todo-list-errors/restapi/operations/todos/add_one_parameters.go b/todo-list-errors/restapi/operations/todos/add_one_parameters.go index f0af1479..ad97a81c 100644 --- a/todo-list-errors/restapi/operations/todos/add_one_parameters.go +++ b/todo-list-errors/restapi/operations/todos/add_one_parameters.go @@ -2,9 +2,6 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - import ( "net/http" diff --git a/todo-list-errors/restapi/operations/todos/add_one_responses.go b/todo-list-errors/restapi/operations/todos/add_one_responses.go index 2028d95f..78cdfd4c 100644 --- a/todo-list-errors/restapi/operations/todos/add_one_responses.go +++ b/todo-list-errors/restapi/operations/todos/add_one_responses.go @@ -2,14 +2,10 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/todo-list-errors/models" ) diff --git a/todo-list-errors/restapi/operations/todos/add_one_urlbuilder.go b/todo-list-errors/restapi/operations/todos/add_one_urlbuilder.go index c5e74a7a..e8eace67 100644 --- a/todo-list-errors/restapi/operations/todos/add_one_urlbuilder.go +++ b/todo-list-errors/restapi/operations/todos/add_one_urlbuilder.go @@ -2,9 +2,6 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - import ( "errors" "net/url" diff --git a/todo-list-errors/restapi/operations/todos/destroy_one.go b/todo-list-errors/restapi/operations/todos/destroy_one.go index 40c00e39..ba8bb1ea 100644 --- a/todo-list-errors/restapi/operations/todos/destroy_one.go +++ b/todo-list-errors/restapi/operations/todos/destroy_one.go @@ -2,9 +2,6 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - import ( "net/http" diff --git a/todo-list-errors/restapi/operations/todos/destroy_one_parameters.go b/todo-list-errors/restapi/operations/todos/destroy_one_parameters.go index bf3c10b9..896b38ed 100644 --- a/todo-list-errors/restapi/operations/todos/destroy_one_parameters.go +++ b/todo-list-errors/restapi/operations/todos/destroy_one_parameters.go @@ -2,9 +2,6 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - import ( "net/http" diff --git a/todo-list-errors/restapi/operations/todos/destroy_one_responses.go b/todo-list-errors/restapi/operations/todos/destroy_one_responses.go index f0bf7c92..9e3ceff1 100644 --- a/todo-list-errors/restapi/operations/todos/destroy_one_responses.go +++ b/todo-list-errors/restapi/operations/todos/destroy_one_responses.go @@ -2,14 +2,10 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/todo-list-errors/models" ) diff --git a/todo-list-errors/restapi/operations/todos/destroy_one_urlbuilder.go b/todo-list-errors/restapi/operations/todos/destroy_one_urlbuilder.go index 2e6ba3d3..15e57f33 100644 --- a/todo-list-errors/restapi/operations/todos/destroy_one_urlbuilder.go +++ b/todo-list-errors/restapi/operations/todos/destroy_one_urlbuilder.go @@ -2,9 +2,6 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - import ( "errors" "net/url" diff --git a/todo-list-errors/restapi/operations/todos/find.go b/todo-list-errors/restapi/operations/todos/find.go index 26790e67..c65b68bb 100644 --- a/todo-list-errors/restapi/operations/todos/find.go +++ b/todo-list-errors/restapi/operations/todos/find.go @@ -2,9 +2,6 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - import ( "net/http" diff --git a/todo-list-errors/restapi/operations/todos/find_parameters.go b/todo-list-errors/restapi/operations/todos/find_parameters.go index 168ff9fb..599a2858 100644 --- a/todo-list-errors/restapi/operations/todos/find_parameters.go +++ b/todo-list-errors/restapi/operations/todos/find_parameters.go @@ -2,9 +2,6 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - import ( stderrors "errors" "fmt" @@ -14,7 +11,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -114,7 +111,7 @@ func (o *FindParams) bindXRateLimit(rawData []string, hasKey bool, formats strfm return err } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("X-Rate-Limit", "header", "int32", raw) } @@ -139,7 +136,7 @@ func (o *FindParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Reg return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "formData", "int32", raw) } @@ -164,7 +161,7 @@ func (o *FindParams) bindTags(rawData []string, hasKey bool, formats strfmt.Regi var tagsIR []int32 for i, tagsIV := range tagsIC { // items.Format: "int32" - tagsI, err := swag.ConvertInt32(tagsIV) + tagsI, err := conv.ConvertInt32(tagsIV) if err != nil { return errors.InvalidType(fmt.Sprintf("%s.%v", "tags", i), "formData", "int32", tagsI) } diff --git a/todo-list-errors/restapi/operations/todos/find_responses.go b/todo-list-errors/restapi/operations/todos/find_responses.go index caf55aa5..5a763663 100644 --- a/todo-list-errors/restapi/operations/todos/find_responses.go +++ b/todo-list-errors/restapi/operations/todos/find_responses.go @@ -2,14 +2,10 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/todo-list-errors/models" ) diff --git a/todo-list-errors/restapi/operations/todos/find_urlbuilder.go b/todo-list-errors/restapi/operations/todos/find_urlbuilder.go index 86f178d8..c0add5ef 100644 --- a/todo-list-errors/restapi/operations/todos/find_urlbuilder.go +++ b/todo-list-errors/restapi/operations/todos/find_urlbuilder.go @@ -2,9 +2,6 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - import ( "errors" "net/url" diff --git a/todo-list-errors/restapi/operations/todos/update_one.go b/todo-list-errors/restapi/operations/todos/update_one.go index 7df374aa..01f45ea0 100644 --- a/todo-list-errors/restapi/operations/todos/update_one.go +++ b/todo-list-errors/restapi/operations/todos/update_one.go @@ -2,9 +2,6 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - import ( "net/http" diff --git a/todo-list-errors/restapi/operations/todos/update_one_parameters.go b/todo-list-errors/restapi/operations/todos/update_one_parameters.go index 6dd5a979..7b761cba 100644 --- a/todo-list-errors/restapi/operations/todos/update_one_parameters.go +++ b/todo-list-errors/restapi/operations/todos/update_one_parameters.go @@ -2,9 +2,6 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - import ( "net/http" diff --git a/todo-list-errors/restapi/operations/todos/update_one_responses.go b/todo-list-errors/restapi/operations/todos/update_one_responses.go index 51a457c5..65976354 100644 --- a/todo-list-errors/restapi/operations/todos/update_one_responses.go +++ b/todo-list-errors/restapi/operations/todos/update_one_responses.go @@ -2,14 +2,10 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/todo-list-errors/models" ) diff --git a/todo-list-errors/restapi/operations/todos/update_one_urlbuilder.go b/todo-list-errors/restapi/operations/todos/update_one_urlbuilder.go index 99740588..1a66cb05 100644 --- a/todo-list-errors/restapi/operations/todos/update_one_urlbuilder.go +++ b/todo-list-errors/restapi/operations/todos/update_one_urlbuilder.go @@ -2,9 +2,6 @@ package todos -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - import ( "errors" "net/url" diff --git a/todo-list-errors/restapi/server.go b/todo-list-errors/restapi/server.go index 919594eb..221b3d50 100644 --- a/todo-list-errors/restapi/server.go +++ b/todo-list-errors/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/todo-list-errors/restapi/operations" ) @@ -370,7 +370,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -385,7 +385,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/todo-list-strict/client/simple_to_do_list_api_client.go b/todo-list-strict/client/simple_to_do_list_api_client.go index 34867647..7223862d 100644 --- a/todo-list-strict/client/simple_to_do_list_api_client.go +++ b/todo-list-strict/client/simple_to_do_list_api_client.go @@ -6,7 +6,6 @@ import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list-strict/client/todos" ) diff --git a/todo-list-strict/client/todos/add_one_parameters.go b/todo-list-strict/client/todos/add_one_parameters.go index a1a002df..8d093874 100644 --- a/todo-list-strict/client/todos/add_one_parameters.go +++ b/todo-list-strict/client/todos/add_one_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list-strict/models" ) diff --git a/todo-list-strict/client/todos/add_one_responses.go b/todo-list-strict/client/todos/add_one_responses.go index aa18a6c4..d348b7e7 100644 --- a/todo-list-strict/client/todos/add_one_responses.go +++ b/todo-list-strict/client/todos/add_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list-strict/models" ) diff --git a/todo-list-strict/client/todos/destroy_one_responses.go b/todo-list-strict/client/todos/destroy_one_responses.go index e76c64b2..b0d92c4f 100644 --- a/todo-list-strict/client/todos/destroy_one_responses.go +++ b/todo-list-strict/client/todos/destroy_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list-strict/models" ) diff --git a/todo-list-strict/client/todos/find_parameters.go b/todo-list-strict/client/todos/find_parameters.go index 095efd7f..7a032320 100644 --- a/todo-list-strict/client/todos/find_parameters.go +++ b/todo-list-strict/client/todos/find_parameters.go @@ -11,7 +11,8 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" + "github.com/go-openapi/swag/stringutils" ) // NewFindParams creates a new FindParams object, @@ -167,13 +168,13 @@ func (o *FindParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry var res []error // header param X-Rate-Limit - if err := r.SetHeaderParam("X-Rate-Limit", swag.FormatInt32(o.XRateLimit)); err != nil { + if err := r.SetHeaderParam("X-Rate-Limit", conv.FormatInteger(o.XRateLimit)); err != nil { return err } // form param limit frLimit := o.Limit - fLimit := swag.FormatInt32(frLimit) + fLimit := conv.FormatInteger(frLimit) if err := r.SetFormParam("limit", fLimit); err != nil { return err } @@ -202,12 +203,12 @@ func (o *FindParams) bindParamTags(formats strfmt.Registry) []string { var tagsIC []string for _, tagsIIR := range tagsIR { // explode []int32 - tagsIIV := swag.FormatInt32(tagsIIR) // int32 as string + tagsIIV := conv.FormatInteger(tagsIIR) // int32 as string tagsIC = append(tagsIC, tagsIIV) } // items.CollectionFormat: "multi" - tagsIS := swag.JoinByFormat(tagsIC, "multi") + tagsIS := stringutils.JoinByFormat(tagsIC, "multi") return tagsIS } diff --git a/todo-list-strict/client/todos/find_responses.go b/todo-list-strict/client/todos/find_responses.go index 3644cdbe..836e82b2 100644 --- a/todo-list-strict/client/todos/find_responses.go +++ b/todo-list-strict/client/todos/find_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list-strict/models" ) diff --git a/todo-list-strict/client/todos/update_one_parameters.go b/todo-list-strict/client/todos/update_one_parameters.go index 344c43e7..e915bc3b 100644 --- a/todo-list-strict/client/todos/update_one_parameters.go +++ b/todo-list-strict/client/todos/update_one_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list-strict/models" ) diff --git a/todo-list-strict/client/todos/update_one_responses.go b/todo-list-strict/client/todos/update_one_responses.go index 1d81cd45..f4fbc68d 100644 --- a/todo-list-strict/client/todos/update_one_responses.go +++ b/todo-list-strict/client/todos/update_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list-strict/models" ) diff --git a/todo-list-strict/models/error.go b/todo-list-strict/models/error.go index 181b96a9..bac28f38 100644 --- a/todo-list-strict/models/error.go +++ b/todo-list-strict/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/todo-list-strict/models/item.go b/todo-list-strict/models/item.go index 2e517784..2e163a96 100644 --- a/todo-list-strict/models/item.go +++ b/todo-list-strict/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/todo-list-strict/restapi/configure_simple_to_do_list_api.go b/todo-list-strict/restapi/configure_simple_to_do_list_api.go index 9c6c4f1b..52c6cefa 100644 --- a/todo-list-strict/restapi/configure_simple_to_do_list_api.go +++ b/todo-list-strict/restapi/configure_simple_to_do_list_api.go @@ -16,7 +16,7 @@ import ( //go:generate swagger generate server --target ../../todo-list-strict --name SimpleToDoListAPI --spec ../swagger.yml --principal any --strict-responders func configureFlags(api *operations.SimpleToDoListAPIAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/todo-list-strict/restapi/operations/simple_to_do_list_api_api.go b/todo-list-strict/restapi/operations/simple_to_do_list_api_api.go index b70daab9..45d45398 100644 --- a/todo-list-strict/restapi/operations/simple_to_do_list_api_api.go +++ b/todo-list-strict/restapi/operations/simple_to_do_list_api_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/todo-list-strict/restapi/operations/todos" ) @@ -146,7 +146,7 @@ type SimpleToDoListAPIAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/todo-list-strict/restapi/operations/todos/add_one_responses.go b/todo-list-strict/restapi/operations/todos/add_one_responses.go index 2434026f..3fbcf247 100644 --- a/todo-list-strict/restapi/operations/todos/add_one_responses.go +++ b/todo-list-strict/restapi/operations/todos/add_one_responses.go @@ -7,7 +7,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - "github.com/go-swagger/examples/todo-list-strict/models" ) diff --git a/todo-list-strict/restapi/operations/todos/destroy_one_responses.go b/todo-list-strict/restapi/operations/todos/destroy_one_responses.go index f65d045c..f04dc266 100644 --- a/todo-list-strict/restapi/operations/todos/destroy_one_responses.go +++ b/todo-list-strict/restapi/operations/todos/destroy_one_responses.go @@ -7,7 +7,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - "github.com/go-swagger/examples/todo-list-strict/models" ) diff --git a/todo-list-strict/restapi/operations/todos/find_parameters.go b/todo-list-strict/restapi/operations/todos/find_parameters.go index 860781a9..599a2858 100644 --- a/todo-list-strict/restapi/operations/todos/find_parameters.go +++ b/todo-list-strict/restapi/operations/todos/find_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -111,7 +111,7 @@ func (o *FindParams) bindXRateLimit(rawData []string, hasKey bool, formats strfm return err } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("X-Rate-Limit", "header", "int32", raw) } @@ -136,7 +136,7 @@ func (o *FindParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Reg return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "formData", "int32", raw) } @@ -161,7 +161,7 @@ func (o *FindParams) bindTags(rawData []string, hasKey bool, formats strfmt.Regi var tagsIR []int32 for i, tagsIV := range tagsIC { // items.Format: "int32" - tagsI, err := swag.ConvertInt32(tagsIV) + tagsI, err := conv.ConvertInt32(tagsIV) if err != nil { return errors.InvalidType(fmt.Sprintf("%s.%v", "tags", i), "formData", "int32", tagsI) } diff --git a/todo-list-strict/restapi/operations/todos/find_responses.go b/todo-list-strict/restapi/operations/todos/find_responses.go index fe056a26..92d434a3 100644 --- a/todo-list-strict/restapi/operations/todos/find_responses.go +++ b/todo-list-strict/restapi/operations/todos/find_responses.go @@ -7,7 +7,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - "github.com/go-swagger/examples/todo-list-strict/models" ) diff --git a/todo-list-strict/restapi/operations/todos/update_one_responses.go b/todo-list-strict/restapi/operations/todos/update_one_responses.go index ed2ece45..59fa5c37 100644 --- a/todo-list-strict/restapi/operations/todos/update_one_responses.go +++ b/todo-list-strict/restapi/operations/todos/update_one_responses.go @@ -7,7 +7,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" - "github.com/go-swagger/examples/todo-list-strict/models" ) diff --git a/todo-list-strict/restapi/server.go b/todo-list-strict/restapi/server.go index 1a992dab..32d3df04 100644 --- a/todo-list-strict/restapi/server.go +++ b/todo-list-strict/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/todo-list-strict/restapi/operations" ) @@ -370,7 +370,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -385,7 +385,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/todo-list/client/todo_list_client.go b/todo-list/client/todo_list_client.go index 50dc48e0..fb0743fd 100644 --- a/todo-list/client/todo_list_client.go +++ b/todo-list/client/todo_list_client.go @@ -6,7 +6,6 @@ import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list/client/todos" ) diff --git a/todo-list/client/todos/add_one_parameters.go b/todo-list/client/todos/add_one_parameters.go index 9c4c6a81..9b3871f1 100644 --- a/todo-list/client/todos/add_one_parameters.go +++ b/todo-list/client/todos/add_one_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list/models" ) diff --git a/todo-list/client/todos/add_one_responses.go b/todo-list/client/todos/add_one_responses.go index 69e1a89a..bce99316 100644 --- a/todo-list/client/todos/add_one_responses.go +++ b/todo-list/client/todos/add_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list/models" ) diff --git a/todo-list/client/todos/destroy_one_responses.go b/todo-list/client/todos/destroy_one_responses.go index 68eb8f79..11866e81 100644 --- a/todo-list/client/todos/destroy_one_responses.go +++ b/todo-list/client/todos/destroy_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list/models" ) diff --git a/todo-list/client/todos/find_parameters.go b/todo-list/client/todos/find_parameters.go index 095efd7f..7a032320 100644 --- a/todo-list/client/todos/find_parameters.go +++ b/todo-list/client/todos/find_parameters.go @@ -11,7 +11,8 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" + "github.com/go-openapi/swag/stringutils" ) // NewFindParams creates a new FindParams object, @@ -167,13 +168,13 @@ func (o *FindParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry var res []error // header param X-Rate-Limit - if err := r.SetHeaderParam("X-Rate-Limit", swag.FormatInt32(o.XRateLimit)); err != nil { + if err := r.SetHeaderParam("X-Rate-Limit", conv.FormatInteger(o.XRateLimit)); err != nil { return err } // form param limit frLimit := o.Limit - fLimit := swag.FormatInt32(frLimit) + fLimit := conv.FormatInteger(frLimit) if err := r.SetFormParam("limit", fLimit); err != nil { return err } @@ -202,12 +203,12 @@ func (o *FindParams) bindParamTags(formats strfmt.Registry) []string { var tagsIC []string for _, tagsIIR := range tagsIR { // explode []int32 - tagsIIV := swag.FormatInt32(tagsIIR) // int32 as string + tagsIIV := conv.FormatInteger(tagsIIR) // int32 as string tagsIC = append(tagsIC, tagsIIV) } // items.CollectionFormat: "multi" - tagsIS := swag.JoinByFormat(tagsIC, "multi") + tagsIS := stringutils.JoinByFormat(tagsIC, "multi") return tagsIS } diff --git a/todo-list/client/todos/find_responses.go b/todo-list/client/todos/find_responses.go index 40468200..9562d21d 100644 --- a/todo-list/client/todos/find_responses.go +++ b/todo-list/client/todos/find_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list/models" ) diff --git a/todo-list/client/todos/update_one_parameters.go b/todo-list/client/todos/update_one_parameters.go index 19b1130e..8577e67a 100644 --- a/todo-list/client/todos/update_one_parameters.go +++ b/todo-list/client/todos/update_one_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list/models" ) diff --git a/todo-list/client/todos/update_one_responses.go b/todo-list/client/todos/update_one_responses.go index 70d07d63..d30e05e6 100644 --- a/todo-list/client/todos/update_one_responses.go +++ b/todo-list/client/todos/update_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/todo-list/models" ) diff --git a/todo-list/models/error.go b/todo-list/models/error.go index 181b96a9..bac28f38 100644 --- a/todo-list/models/error.go +++ b/todo-list/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/todo-list/models/item.go b/todo-list/models/item.go index 2e517784..2e163a96 100644 --- a/todo-list/models/item.go +++ b/todo-list/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/todo-list/restapi/configure_todo_list.go b/todo-list/restapi/configure_todo_list.go index f5c43335..48d17e85 100644 --- a/todo-list/restapi/configure_todo_list.go +++ b/todo-list/restapi/configure_todo_list.go @@ -17,7 +17,7 @@ import ( //go:generate swagger generate server --target ../../todo-list --name TodoList --spec ../swagger.yml --principal any func configureFlags(api *operations.TodoListAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/todo-list/restapi/operations/todo_list_api.go b/todo-list/restapi/operations/todo_list_api.go index d666cb2e..1050db6c 100644 --- a/todo-list/restapi/operations/todo_list_api.go +++ b/todo-list/restapi/operations/todo_list_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/todo-list/restapi/operations/todos" ) @@ -146,7 +146,7 @@ type TodoListAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/todo-list/restapi/operations/todos/add_one_responses.go b/todo-list/restapi/operations/todos/add_one_responses.go index ae91f955..4d7b43ff 100644 --- a/todo-list/restapi/operations/todos/add_one_responses.go +++ b/todo-list/restapi/operations/todos/add_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/todo-list/models" ) diff --git a/todo-list/restapi/operations/todos/destroy_one_responses.go b/todo-list/restapi/operations/todos/destroy_one_responses.go index a3babc3e..bb043e86 100644 --- a/todo-list/restapi/operations/todos/destroy_one_responses.go +++ b/todo-list/restapi/operations/todos/destroy_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/todo-list/models" ) diff --git a/todo-list/restapi/operations/todos/find_parameters.go b/todo-list/restapi/operations/todos/find_parameters.go index 860781a9..599a2858 100644 --- a/todo-list/restapi/operations/todos/find_parameters.go +++ b/todo-list/restapi/operations/todos/find_parameters.go @@ -11,7 +11,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" ) @@ -111,7 +111,7 @@ func (o *FindParams) bindXRateLimit(rawData []string, hasKey bool, formats strfm return err } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("X-Rate-Limit", "header", "int32", raw) } @@ -136,7 +136,7 @@ func (o *FindParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Reg return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "formData", "int32", raw) } @@ -161,7 +161,7 @@ func (o *FindParams) bindTags(rawData []string, hasKey bool, formats strfmt.Regi var tagsIR []int32 for i, tagsIV := range tagsIC { // items.Format: "int32" - tagsI, err := swag.ConvertInt32(tagsIV) + tagsI, err := conv.ConvertInt32(tagsIV) if err != nil { return errors.InvalidType(fmt.Sprintf("%s.%v", "tags", i), "formData", "int32", tagsI) } diff --git a/todo-list/restapi/operations/todos/find_responses.go b/todo-list/restapi/operations/todos/find_responses.go index 35870d0c..3762241c 100644 --- a/todo-list/restapi/operations/todos/find_responses.go +++ b/todo-list/restapi/operations/todos/find_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/todo-list/models" ) diff --git a/todo-list/restapi/operations/todos/update_one_responses.go b/todo-list/restapi/operations/todos/update_one_responses.go index ce9daf75..827db1d8 100644 --- a/todo-list/restapi/operations/todos/update_one_responses.go +++ b/todo-list/restapi/operations/todos/update_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/todo-list/models" ) diff --git a/todo-list/restapi/server.go b/todo-list/restapi/server.go index fbce6317..1465e13d 100644 --- a/todo-list/restapi/server.go +++ b/todo-list/restapi/server.go @@ -23,7 +23,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/todo-list/restapi/operations" ) @@ -473,7 +473,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -488,7 +488,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/tutorials/client/classic_client/experimental/get_experimental_responses.go b/tutorials/client/classic_client/experimental/get_experimental_responses.go index 28a78872..de7a3d4c 100644 --- a/tutorials/client/classic_client/experimental/get_experimental_responses.go +++ b/tutorials/client/classic_client/experimental/get_experimental_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/classic_client/experimental/put_experimental_parameters.go b/tutorials/client/classic_client/experimental/put_experimental_parameters.go index 7ad0682f..54a8d24a 100644 --- a/tutorials/client/classic_client/experimental/put_experimental_parameters.go +++ b/tutorials/client/classic_client/experimental/put_experimental_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/classic_client/experimental/put_experimental_responses.go b/tutorials/client/classic_client/experimental/put_experimental_responses.go index 897bc759..1f6f98db 100644 --- a/tutorials/client/classic_client/experimental/put_experimental_responses.go +++ b/tutorials/client/classic_client/experimental/put_experimental_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/classic_client/todo_list_client.go b/tutorials/client/classic_client/todo_list_client.go index 0421c905..2c49ab77 100644 --- a/tutorials/client/classic_client/todo_list_client.go +++ b/tutorials/client/classic_client/todo_list_client.go @@ -6,7 +6,6 @@ import ( "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/classic_client/experimental" "github.com/go-swagger/examples/tutorials/client/classic_client/todos" ) diff --git a/tutorials/client/classic_client/todos/add_one_parameters.go b/tutorials/client/classic_client/todos/add_one_parameters.go index 57e4d381..06c18fe2 100644 --- a/tutorials/client/classic_client/todos/add_one_parameters.go +++ b/tutorials/client/classic_client/todos/add_one_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/classic_client/todos/add_one_responses.go b/tutorials/client/classic_client/todos/add_one_responses.go index 6d0f7f45..4ca2710a 100644 --- a/tutorials/client/classic_client/todos/add_one_responses.go +++ b/tutorials/client/classic_client/todos/add_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/classic_client/todos/destroy_one_responses.go b/tutorials/client/classic_client/todos/destroy_one_responses.go index a91158ad..b047e66c 100644 --- a/tutorials/client/classic_client/todos/destroy_one_responses.go +++ b/tutorials/client/classic_client/todos/destroy_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/classic_client/todos/find_parameters.go b/tutorials/client/classic_client/todos/find_parameters.go index 095efd7f..7a032320 100644 --- a/tutorials/client/classic_client/todos/find_parameters.go +++ b/tutorials/client/classic_client/todos/find_parameters.go @@ -11,7 +11,8 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" + "github.com/go-openapi/swag/stringutils" ) // NewFindParams creates a new FindParams object, @@ -167,13 +168,13 @@ func (o *FindParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry var res []error // header param X-Rate-Limit - if err := r.SetHeaderParam("X-Rate-Limit", swag.FormatInt32(o.XRateLimit)); err != nil { + if err := r.SetHeaderParam("X-Rate-Limit", conv.FormatInteger(o.XRateLimit)); err != nil { return err } // form param limit frLimit := o.Limit - fLimit := swag.FormatInt32(frLimit) + fLimit := conv.FormatInteger(frLimit) if err := r.SetFormParam("limit", fLimit); err != nil { return err } @@ -202,12 +203,12 @@ func (o *FindParams) bindParamTags(formats strfmt.Registry) []string { var tagsIC []string for _, tagsIIR := range tagsIR { // explode []int32 - tagsIIV := swag.FormatInt32(tagsIIR) // int32 as string + tagsIIV := conv.FormatInteger(tagsIIR) // int32 as string tagsIC = append(tagsIC, tagsIIV) } // items.CollectionFormat: "multi" - tagsIS := swag.JoinByFormat(tagsIC, "multi") + tagsIS := stringutils.JoinByFormat(tagsIC, "multi") return tagsIS } diff --git a/tutorials/client/classic_client/todos/find_responses.go b/tutorials/client/classic_client/todos/find_responses.go index c3b65436..5f9ad10a 100644 --- a/tutorials/client/classic_client/todos/find_responses.go +++ b/tutorials/client/classic_client/todos/find_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/classic_client/todos/update_one_parameters.go b/tutorials/client/classic_client/todos/update_one_parameters.go index ccc04bfa..acadccf1 100644 --- a/tutorials/client/classic_client/todos/update_one_parameters.go +++ b/tutorials/client/classic_client/todos/update_one_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/classic_client/todos/update_one_responses.go b/tutorials/client/classic_client/todos/update_one_responses.go index fa102b95..dbad7874 100644 --- a/tutorials/client/classic_client/todos/update_one_responses.go +++ b/tutorials/client/classic_client/todos/update_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/models/error.go b/tutorials/client/models/error.go index 181b96a9..bac28f38 100644 --- a/tutorials/client/models/error.go +++ b/tutorials/client/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/tutorials/client/models/item.go b/tutorials/client/models/item.go index 2e517784..2e163a96 100644 --- a/tutorials/client/models/item.go +++ b/tutorials/client/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/tutorials/client/stratoscale_client/experimental/experimental_client.go b/tutorials/client/stratoscale_client/experimental/experimental_client.go index bede77c9..514133c0 100644 --- a/tutorials/client/stratoscale_client/experimental/experimental_client.go +++ b/tutorials/client/stratoscale_client/experimental/experimental_client.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/go-openapi/runtime" - strfmt "github.com/go-openapi/strfmt" ) diff --git a/tutorials/client/stratoscale_client/experimental/get_experimental_responses.go b/tutorials/client/stratoscale_client/experimental/get_experimental_responses.go index 28a78872..de7a3d4c 100644 --- a/tutorials/client/stratoscale_client/experimental/get_experimental_responses.go +++ b/tutorials/client/stratoscale_client/experimental/get_experimental_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/stratoscale_client/experimental/put_experimental_parameters.go b/tutorials/client/stratoscale_client/experimental/put_experimental_parameters.go index 7ad0682f..54a8d24a 100644 --- a/tutorials/client/stratoscale_client/experimental/put_experimental_parameters.go +++ b/tutorials/client/stratoscale_client/experimental/put_experimental_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/stratoscale_client/experimental/put_experimental_responses.go b/tutorials/client/stratoscale_client/experimental/put_experimental_responses.go index 897bc759..1f6f98db 100644 --- a/tutorials/client/stratoscale_client/experimental/put_experimental_responses.go +++ b/tutorials/client/stratoscale_client/experimental/put_experimental_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/stratoscale_client/todo_list_client.go b/tutorials/client/stratoscale_client/todo_list_client.go index c344532a..0e0ecba5 100644 --- a/tutorials/client/stratoscale_client/todo_list_client.go +++ b/tutorials/client/stratoscale_client/todo_list_client.go @@ -9,7 +9,6 @@ import ( "github.com/go-openapi/runtime" rtclient "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/stratoscale_client/experimental" "github.com/go-swagger/examples/tutorials/client/stratoscale_client/todos" ) diff --git a/tutorials/client/stratoscale_client/todos/add_one_parameters.go b/tutorials/client/stratoscale_client/todos/add_one_parameters.go index 57e4d381..06c18fe2 100644 --- a/tutorials/client/stratoscale_client/todos/add_one_parameters.go +++ b/tutorials/client/stratoscale_client/todos/add_one_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/stratoscale_client/todos/add_one_responses.go b/tutorials/client/stratoscale_client/todos/add_one_responses.go index 6d0f7f45..4ca2710a 100644 --- a/tutorials/client/stratoscale_client/todos/add_one_responses.go +++ b/tutorials/client/stratoscale_client/todos/add_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/stratoscale_client/todos/destroy_one_responses.go b/tutorials/client/stratoscale_client/todos/destroy_one_responses.go index a91158ad..b047e66c 100644 --- a/tutorials/client/stratoscale_client/todos/destroy_one_responses.go +++ b/tutorials/client/stratoscale_client/todos/destroy_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/stratoscale_client/todos/find_parameters.go b/tutorials/client/stratoscale_client/todos/find_parameters.go index 095efd7f..7a032320 100644 --- a/tutorials/client/stratoscale_client/todos/find_parameters.go +++ b/tutorials/client/stratoscale_client/todos/find_parameters.go @@ -11,7 +11,8 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" + "github.com/go-openapi/swag/stringutils" ) // NewFindParams creates a new FindParams object, @@ -167,13 +168,13 @@ func (o *FindParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry var res []error // header param X-Rate-Limit - if err := r.SetHeaderParam("X-Rate-Limit", swag.FormatInt32(o.XRateLimit)); err != nil { + if err := r.SetHeaderParam("X-Rate-Limit", conv.FormatInteger(o.XRateLimit)); err != nil { return err } // form param limit frLimit := o.Limit - fLimit := swag.FormatInt32(frLimit) + fLimit := conv.FormatInteger(frLimit) if err := r.SetFormParam("limit", fLimit); err != nil { return err } @@ -202,12 +203,12 @@ func (o *FindParams) bindParamTags(formats strfmt.Registry) []string { var tagsIC []string for _, tagsIIR := range tagsIR { // explode []int32 - tagsIIV := swag.FormatInt32(tagsIIR) // int32 as string + tagsIIV := conv.FormatInteger(tagsIIR) // int32 as string tagsIC = append(tagsIC, tagsIIV) } // items.CollectionFormat: "multi" - tagsIS := swag.JoinByFormat(tagsIC, "multi") + tagsIS := stringutils.JoinByFormat(tagsIC, "multi") return tagsIS } diff --git a/tutorials/client/stratoscale_client/todos/find_responses.go b/tutorials/client/stratoscale_client/todos/find_responses.go index c3b65436..5f9ad10a 100644 --- a/tutorials/client/stratoscale_client/todos/find_responses.go +++ b/tutorials/client/stratoscale_client/todos/find_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/stratoscale_client/todos/todos_client.go b/tutorials/client/stratoscale_client/todos/todos_client.go index da71c079..ba7bdaf2 100644 --- a/tutorials/client/stratoscale_client/todos/todos_client.go +++ b/tutorials/client/stratoscale_client/todos/todos_client.go @@ -6,7 +6,6 @@ import ( "context" "github.com/go-openapi/runtime" - strfmt "github.com/go-openapi/strfmt" ) diff --git a/tutorials/client/stratoscale_client/todos/update_one_parameters.go b/tutorials/client/stratoscale_client/todos/update_one_parameters.go index ccc04bfa..acadccf1 100644 --- a/tutorials/client/stratoscale_client/todos/update_one_parameters.go +++ b/tutorials/client/stratoscale_client/todos/update_one_parameters.go @@ -11,7 +11,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/client/stratoscale_client/todos/update_one_responses.go b/tutorials/client/stratoscale_client/todos/update_one_responses.go index fa102b95..dbad7874 100644 --- a/tutorials/client/stratoscale_client/todos/update_one_responses.go +++ b/tutorials/client/stratoscale_client/todos/update_one_responses.go @@ -10,7 +10,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/go-swagger/examples/tutorials/client/models" ) diff --git a/tutorials/custom-server/cmd/greeter/main.go b/tutorials/custom-server/cmd/greeter/main.go index 7e266dc9..ea9a7639 100644 --- a/tutorials/custom-server/cmd/greeter/main.go +++ b/tutorials/custom-server/cmd/greeter/main.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/loads" "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-swagger/examples/tutorials/custom-server/gen/restapi" "github.com/go-swagger/examples/tutorials/custom-server/gen/restapi/operations" @@ -44,7 +44,7 @@ func serve() error { // in case the name is not given, it will default to World api.GetGreetingHandler = operations.GetGreetingHandlerFunc( func(params operations.GetGreetingParams) middleware.Responder { - name := swag.StringValue(params.Name) + name := conv.Value(params.Name) if name == "" { name = "World" } diff --git a/tutorials/custom-server/gen/restapi/configure_greeter.go b/tutorials/custom-server/gen/restapi/configure_greeter.go index c93e3086..a89f21a8 100644 --- a/tutorials/custom-server/gen/restapi/configure_greeter.go +++ b/tutorials/custom-server/gen/restapi/configure_greeter.go @@ -16,7 +16,7 @@ import ( //go:generate swagger generate server --target ../../gen --name Greeter --spec ../../swagger/swagger.yml --principal any --exclude-main func configureFlags(api *operations.GreeterAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/tutorials/custom-server/gen/restapi/operations/greeter_api.go b/tutorials/custom-server/gen/restapi/operations/greeter_api.go index ad355398..47b57fa5 100644 --- a/tutorials/custom-server/gen/restapi/operations/greeter_api.go +++ b/tutorials/custom-server/gen/restapi/operations/greeter_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" ) // NewGreeterAPI creates a new Greeter instance @@ -96,7 +96,7 @@ type GreeterAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/tutorials/custom-server/gen/restapi/server.go b/tutorials/custom-server/gen/restapi/server.go index 75d290ed..d86eaf47 100644 --- a/tutorials/custom-server/gen/restapi/server.go +++ b/tutorials/custom-server/gen/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/tutorials/custom-server/gen/restapi/operations" ) @@ -368,7 +368,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -383,7 +383,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/tutorials/todo-list/dynamic-untyped/main.go b/tutorials/todo-list/dynamic-untyped/main.go index d311de8c..71b6ebcb 100644 --- a/tutorials/todo-list/dynamic-untyped/main.go +++ b/tutorials/todo-list/dynamic-untyped/main.go @@ -1,7 +1,9 @@ +//nolint:forcetypeassert // type assertions left unchecked for brevity package main import ( "log" + "maps" "net/http" "os" "sync" @@ -95,7 +97,7 @@ var destroyOne = runtime.OperationHandlerFunc(func(params any) (any, error) { log.Printf("%#v\n", params) removeItem(params.(map[string]any)["id"].(int64)) - return nil, nil + return nil, nil //nolint:nilnil // for demo purpose we don't return any response }) var items = []map[string]any{ @@ -128,9 +130,8 @@ func updateItem(id int64, body map[string]any) (map[string]any, error) { return nil, err } delete(body, "id") - for k, v := range body { - item[k] = v - } + maps.Copy(item, body) + return item, nil } diff --git a/tutorials/todo-list/server-1/models/error.go b/tutorials/todo-list/server-1/models/error.go index 181b96a9..bac28f38 100644 --- a/tutorials/todo-list/server-1/models/error.go +++ b/tutorials/todo-list/server-1/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/tutorials/todo-list/server-1/models/item.go b/tutorials/todo-list/server-1/models/item.go index 2e517784..2e163a96 100644 --- a/tutorials/todo-list/server-1/models/item.go +++ b/tutorials/todo-list/server-1/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/tutorials/todo-list/server-1/restapi/configure_todo_list.go b/tutorials/todo-list/server-1/restapi/configure_todo_list.go index 045c13a0..a3c14e4f 100644 --- a/tutorials/todo-list/server-1/restapi/configure_todo_list.go +++ b/tutorials/todo-list/server-1/restapi/configure_todo_list.go @@ -17,7 +17,7 @@ import ( //go:generate swagger generate server --target ../../server-1 --name TodoList --spec ../swagger.yml --principal any func configureFlags(api *operations.TodoListAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/tutorials/todo-list/server-1/restapi/operations/todo_list_api.go b/tutorials/todo-list/server-1/restapi/operations/todo_list_api.go index 5bd961db..d47ed6e6 100644 --- a/tutorials/todo-list/server-1/restapi/operations/todo_list_api.go +++ b/tutorials/todo-list/server-1/restapi/operations/todo_list_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/tutorials/todo-list/server-1/restapi/operations/todos" ) @@ -98,7 +98,7 @@ type TodoListAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/tutorials/todo-list/server-1/restapi/operations/todos/find_todos_parameters.go b/tutorials/todo-list/server-1/restapi/operations/todos/find_todos_parameters.go index 3472ad6f..8fbe147d 100644 --- a/tutorials/todo-list/server-1/restapi/operations/todos/find_todos_parameters.go +++ b/tutorials/todo-list/server-1/restapi/operations/todos/find_todos_parameters.go @@ -9,7 +9,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewFindTodosParams creates a new FindTodosParams object @@ -87,7 +87,7 @@ func (o *FindTodosParams) bindLimit(rawData []string, hasKey bool, formats strfm return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "query", "int32", raw) } @@ -110,7 +110,7 @@ func (o *FindTodosParams) bindSince(rawData []string, hasKey bool, formats strfm return nil } - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("since", "query", "int64", raw) } diff --git a/tutorials/todo-list/server-1/restapi/operations/todos/find_todos_responses.go b/tutorials/todo-list/server-1/restapi/operations/todos/find_todos_responses.go index f6ee5dbb..51d98177 100644 --- a/tutorials/todo-list/server-1/restapi/operations/todos/find_todos_responses.go +++ b/tutorials/todo-list/server-1/restapi/operations/todos/find_todos_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/tutorials/todo-list/server-1/models" ) diff --git a/tutorials/todo-list/server-1/restapi/operations/todos/find_todos_urlbuilder.go b/tutorials/todo-list/server-1/restapi/operations/todos/find_todos_urlbuilder.go index 825eeb4e..5472135f 100644 --- a/tutorials/todo-list/server-1/restapi/operations/todos/find_todos_urlbuilder.go +++ b/tutorials/todo-list/server-1/restapi/operations/todos/find_todos_urlbuilder.go @@ -7,7 +7,7 @@ import ( "net/url" golangswaggerpaths "path" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // FindTodosURL generates an URL for the find todos operation @@ -48,7 +48,7 @@ func (o *FindTodosURL) Build() (*url.URL, error) { var limitQ string if o.Limit != nil { - limitQ = swag.FormatInt32(*o.Limit) + limitQ = conv.FormatInteger(*o.Limit) } if limitQ != "" { qs.Set("limit", limitQ) @@ -56,7 +56,7 @@ func (o *FindTodosURL) Build() (*url.URL, error) { var sinceQ string if o.Since != nil { - sinceQ = swag.FormatInt64(*o.Since) + sinceQ = conv.FormatInteger(*o.Since) } if sinceQ != "" { qs.Set("since", sinceQ) diff --git a/tutorials/todo-list/server-1/restapi/server.go b/tutorials/todo-list/server-1/restapi/server.go index 38c1099c..062af349 100644 --- a/tutorials/todo-list/server-1/restapi/server.go +++ b/tutorials/todo-list/server-1/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/tutorials/todo-list/server-1/restapi/operations" ) @@ -368,7 +368,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -383,7 +383,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/tutorials/todo-list/server-2/models/error.go b/tutorials/todo-list/server-2/models/error.go index 181b96a9..bac28f38 100644 --- a/tutorials/todo-list/server-2/models/error.go +++ b/tutorials/todo-list/server-2/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/tutorials/todo-list/server-2/models/item.go b/tutorials/todo-list/server-2/models/item.go index 2e517784..2e163a96 100644 --- a/tutorials/todo-list/server-2/models/item.go +++ b/tutorials/todo-list/server-2/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/tutorials/todo-list/server-2/restapi/configure_todo_list.go b/tutorials/todo-list/server-2/restapi/configure_todo_list.go index ea5b2c21..4b6579b9 100644 --- a/tutorials/todo-list/server-2/restapi/configure_todo_list.go +++ b/tutorials/todo-list/server-2/restapi/configure_todo_list.go @@ -17,7 +17,7 @@ import ( //go:generate swagger generate server --target ../../server-2 --name TodoList --spec ../swagger.yml --principal any func configureFlags(api *operations.TodoListAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } + // api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ ... } _ = api } diff --git a/tutorials/todo-list/server-2/restapi/operations/todo_list_api.go b/tutorials/todo-list/server-2/restapi/operations/todo_list_api.go index f13cc83a..4577832c 100644 --- a/tutorials/todo-list/server-2/restapi/operations/todo_list_api.go +++ b/tutorials/todo-list/server-2/restapi/operations/todo_list_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/tutorials/todo-list/server-2/restapi/operations/todos" ) @@ -122,7 +122,7 @@ type TodoListAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/tutorials/todo-list/server-2/restapi/operations/todos/add_one_responses.go b/tutorials/todo-list/server-2/restapi/operations/todos/add_one_responses.go index b442e07e..8b13d05a 100644 --- a/tutorials/todo-list/server-2/restapi/operations/todos/add_one_responses.go +++ b/tutorials/todo-list/server-2/restapi/operations/todos/add_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/tutorials/todo-list/server-2/models" ) diff --git a/tutorials/todo-list/server-2/restapi/operations/todos/destroy_one_parameters.go b/tutorials/todo-list/server-2/restapi/operations/todos/destroy_one_parameters.go index 3322808a..ab647b06 100644 --- a/tutorials/todo-list/server-2/restapi/operations/todos/destroy_one_parameters.go +++ b/tutorials/todo-list/server-2/restapi/operations/todos/destroy_one_parameters.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewDestroyOneParams creates a new DestroyOneParams object @@ -63,7 +63,7 @@ func (o *DestroyOneParams) bindID(rawData []string, hasKey bool, formats strfmt. // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("id", "path", "int64", raw) } diff --git a/tutorials/todo-list/server-2/restapi/operations/todos/destroy_one_responses.go b/tutorials/todo-list/server-2/restapi/operations/todos/destroy_one_responses.go index 9c6543fb..39cc7a0e 100644 --- a/tutorials/todo-list/server-2/restapi/operations/todos/destroy_one_responses.go +++ b/tutorials/todo-list/server-2/restapi/operations/todos/destroy_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/tutorials/todo-list/server-2/models" ) diff --git a/tutorials/todo-list/server-2/restapi/operations/todos/destroy_one_urlbuilder.go b/tutorials/todo-list/server-2/restapi/operations/todos/destroy_one_urlbuilder.go index fa4417ce..975fbefc 100644 --- a/tutorials/todo-list/server-2/restapi/operations/todos/destroy_one_urlbuilder.go +++ b/tutorials/todo-list/server-2/restapi/operations/todos/destroy_one_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // DestroyOneURL generates an URL for the destroy one operation @@ -41,7 +41,7 @@ func (o *DestroyOneURL) Build() (*url.URL, error) { var _path = "/{id}" - id := swag.FormatInt64(o.ID) + id := conv.FormatInteger(o.ID) if id != "" { _path = strings.ReplaceAll(_path, "{id}", id) } else { diff --git a/tutorials/todo-list/server-2/restapi/operations/todos/find_todos_parameters.go b/tutorials/todo-list/server-2/restapi/operations/todos/find_todos_parameters.go index 3472ad6f..8fbe147d 100644 --- a/tutorials/todo-list/server-2/restapi/operations/todos/find_todos_parameters.go +++ b/tutorials/todo-list/server-2/restapi/operations/todos/find_todos_parameters.go @@ -9,7 +9,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewFindTodosParams creates a new FindTodosParams object @@ -87,7 +87,7 @@ func (o *FindTodosParams) bindLimit(rawData []string, hasKey bool, formats strfm return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "query", "int32", raw) } @@ -110,7 +110,7 @@ func (o *FindTodosParams) bindSince(rawData []string, hasKey bool, formats strfm return nil } - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("since", "query", "int64", raw) } diff --git a/tutorials/todo-list/server-2/restapi/operations/todos/find_todos_responses.go b/tutorials/todo-list/server-2/restapi/operations/todos/find_todos_responses.go index 73a06040..69a9fe29 100644 --- a/tutorials/todo-list/server-2/restapi/operations/todos/find_todos_responses.go +++ b/tutorials/todo-list/server-2/restapi/operations/todos/find_todos_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/tutorials/todo-list/server-2/models" ) diff --git a/tutorials/todo-list/server-2/restapi/operations/todos/find_todos_urlbuilder.go b/tutorials/todo-list/server-2/restapi/operations/todos/find_todos_urlbuilder.go index 825eeb4e..5472135f 100644 --- a/tutorials/todo-list/server-2/restapi/operations/todos/find_todos_urlbuilder.go +++ b/tutorials/todo-list/server-2/restapi/operations/todos/find_todos_urlbuilder.go @@ -7,7 +7,7 @@ import ( "net/url" golangswaggerpaths "path" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // FindTodosURL generates an URL for the find todos operation @@ -48,7 +48,7 @@ func (o *FindTodosURL) Build() (*url.URL, error) { var limitQ string if o.Limit != nil { - limitQ = swag.FormatInt32(*o.Limit) + limitQ = conv.FormatInteger(*o.Limit) } if limitQ != "" { qs.Set("limit", limitQ) @@ -56,7 +56,7 @@ func (o *FindTodosURL) Build() (*url.URL, error) { var sinceQ string if o.Since != nil { - sinceQ = swag.FormatInt64(*o.Since) + sinceQ = conv.FormatInteger(*o.Since) } if sinceQ != "" { qs.Set("since", sinceQ) diff --git a/tutorials/todo-list/server-2/restapi/operations/todos/update_one_parameters.go b/tutorials/todo-list/server-2/restapi/operations/todos/update_one_parameters.go index 1b7a7f63..02688a6d 100644 --- a/tutorials/todo-list/server-2/restapi/operations/todos/update_one_parameters.go +++ b/tutorials/todo-list/server-2/restapi/operations/todos/update_one_parameters.go @@ -9,7 +9,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" "github.com/go-swagger/examples/tutorials/todo-list/server-2/models" @@ -96,7 +96,7 @@ func (o *UpdateOneParams) bindID(rawData []string, hasKey bool, formats strfmt.R // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("id", "path", "int64", raw) } diff --git a/tutorials/todo-list/server-2/restapi/operations/todos/update_one_responses.go b/tutorials/todo-list/server-2/restapi/operations/todos/update_one_responses.go index 7ef38362..2564a3e5 100644 --- a/tutorials/todo-list/server-2/restapi/operations/todos/update_one_responses.go +++ b/tutorials/todo-list/server-2/restapi/operations/todos/update_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/tutorials/todo-list/server-2/models" ) diff --git a/tutorials/todo-list/server-2/restapi/operations/todos/update_one_urlbuilder.go b/tutorials/todo-list/server-2/restapi/operations/todos/update_one_urlbuilder.go index 745deca3..1eb25473 100644 --- a/tutorials/todo-list/server-2/restapi/operations/todos/update_one_urlbuilder.go +++ b/tutorials/todo-list/server-2/restapi/operations/todos/update_one_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // UpdateOneURL generates an URL for the update one operation @@ -41,7 +41,7 @@ func (o *UpdateOneURL) Build() (*url.URL, error) { var _path = "/{id}" - id := swag.FormatInt64(o.ID) + id := conv.FormatInteger(o.ID) if id != "" { _path = strings.ReplaceAll(_path, "{id}", id) } else { diff --git a/tutorials/todo-list/server-2/restapi/server.go b/tutorials/todo-list/server-2/restapi/server.go index 713f7fd7..58cb35db 100644 --- a/tutorials/todo-list/server-2/restapi/server.go +++ b/tutorials/todo-list/server-2/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/tutorials/todo-list/server-2/restapi/operations" ) @@ -368,7 +368,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -383,7 +383,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err } diff --git a/tutorials/todo-list/server-complete/models/error.go b/tutorials/todo-list/server-complete/models/error.go index 181b96a9..bac28f38 100644 --- a/tutorials/todo-list/server-complete/models/error.go +++ b/tutorials/todo-list/server-complete/models/error.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -57,13 +57,13 @@ func (m *Error) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Error) UnmarshalBinary(b []byte) error { var res Error - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/tutorials/todo-list/server-complete/models/item.go b/tutorials/todo-list/server-complete/models/item.go index 2e517784..2e163a96 100644 --- a/tutorials/todo-list/server-complete/models/item.go +++ b/tutorials/todo-list/server-complete/models/item.go @@ -7,7 +7,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/jsonutils" "github.com/go-openapi/validate" ) @@ -84,13 +84,13 @@ func (m *Item) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } - return swag.WriteJSON(m) + return jsonutils.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Item) UnmarshalBinary(b []byte) error { var res Item - if err := swag.ReadJSON(b, &res); err != nil { + if err := jsonutils.ReadJSON(b, &res); err != nil { return err } *m = res diff --git a/tutorials/todo-list/server-complete/restapi/configure_todo_list.go b/tutorials/todo-list/server-complete/restapi/configure_todo_list.go index f8d5ee61..2986594d 100644 --- a/tutorials/todo-list/server-complete/restapi/configure_todo_list.go +++ b/tutorials/todo-list/server-complete/restapi/configure_todo_list.go @@ -12,7 +12,8 @@ import ( errors "github.com/go-openapi/errors" runtime "github.com/go-openapi/runtime" middleware "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" + "github.com/go-openapi/swag/conv" "github.com/go-swagger/examples/tutorials/todo-list/server-complete/models" "github.com/go-swagger/examples/tutorials/todo-list/server-complete/restapi/operations" @@ -27,7 +28,7 @@ var exampleFlags = struct { }{} func configureFlags(api *operations.TodoListAPI) { - api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ + api.CommandLineOptionsGroups = []cmdutils.CommandLineOptionsGroup{ { ShortDescription: "Example Flags", LongDescription: "", @@ -38,13 +39,13 @@ func configureFlags(api *operations.TodoListAPI) { var ( items = make(map[int64]*models.Item) - lastID int64 + lastID atomic.Int64 ) var itemsLock = &sync.Mutex{} func newItemID() int64 { - return atomic.AddInt64(&lastID, 1) + return lastID.Add(1) } func addItem(item *models.Item) error { @@ -122,19 +123,19 @@ func configureAPI(api *operations.TodoListAPI) http.Handler { api.TodosAddOneHandler = todos.AddOneHandlerFunc(func(params todos.AddOneParams) middleware.Responder { if err := addItem(params.Body); err != nil { - return todos.NewAddOneDefault(500).WithPayload(&models.Error{Code: 500, Message: swag.String(err.Error())}) + return todos.NewAddOneDefault(500).WithPayload(&models.Error{Code: 500, Message: conv.Pointer(err.Error())}) } return todos.NewAddOneCreated().WithPayload(params.Body) }) api.TodosDestroyOneHandler = todos.DestroyOneHandlerFunc(func(params todos.DestroyOneParams) middleware.Responder { if err := deleteItem(params.ID); err != nil { - return todos.NewDestroyOneDefault(500).WithPayload(&models.Error{Code: 500, Message: swag.String(err.Error())}) + return todos.NewDestroyOneDefault(500).WithPayload(&models.Error{Code: 500, Message: conv.Pointer(err.Error())}) } return todos.NewDestroyOneNoContent() }) api.TodosFindTodosHandler = todos.FindTodosHandlerFunc(func(params todos.FindTodosParams) middleware.Responder { mergedParams := todos.NewFindTodosParams() - mergedParams.Since = swag.Int64(0) + mergedParams.Since = conv.Pointer(int64(0)) if params.Since != nil { mergedParams.Since = params.Since } @@ -145,7 +146,7 @@ func configureAPI(api *operations.TodoListAPI) http.Handler { }) api.TodosUpdateOneHandler = todos.UpdateOneHandlerFunc(func(params todos.UpdateOneParams) middleware.Responder { if err := updateItem(params.ID, params.Body); err != nil { - return todos.NewUpdateOneDefault(500).WithPayload(&models.Error{Code: 500, Message: swag.String(err.Error())}) + return todos.NewUpdateOneDefault(500).WithPayload(&models.Error{Code: 500, Message: conv.Pointer(err.Error())}) } return todos.NewUpdateOneOK().WithPayload(params.Body) }) diff --git a/tutorials/todo-list/server-complete/restapi/operations/todo_list_api.go b/tutorials/todo-list/server-complete/restapi/operations/todo_list_api.go index 4274a0b5..28093931 100644 --- a/tutorials/todo-list/server-complete/restapi/operations/todo_list_api.go +++ b/tutorials/todo-list/server-complete/restapi/operations/todo_list_api.go @@ -14,7 +14,7 @@ import ( "github.com/go-openapi/runtime/security" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/cmdutils" "github.com/go-swagger/examples/tutorials/todo-list/server-complete/restapi/operations/todos" ) @@ -122,7 +122,7 @@ type TodoListAPI struct { ServerShutdown func() // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup + CommandLineOptionsGroups []cmdutils.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...any) diff --git a/tutorials/todo-list/server-complete/restapi/operations/todos/add_one_responses.go b/tutorials/todo-list/server-complete/restapi/operations/todos/add_one_responses.go index a8f0ea74..97c0d4bf 100644 --- a/tutorials/todo-list/server-complete/restapi/operations/todos/add_one_responses.go +++ b/tutorials/todo-list/server-complete/restapi/operations/todos/add_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/tutorials/todo-list/server-complete/models" ) diff --git a/tutorials/todo-list/server-complete/restapi/operations/todos/destroy_one_parameters.go b/tutorials/todo-list/server-complete/restapi/operations/todos/destroy_one_parameters.go index 3322808a..ab647b06 100644 --- a/tutorials/todo-list/server-complete/restapi/operations/todos/destroy_one_parameters.go +++ b/tutorials/todo-list/server-complete/restapi/operations/todos/destroy_one_parameters.go @@ -8,7 +8,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewDestroyOneParams creates a new DestroyOneParams object @@ -63,7 +63,7 @@ func (o *DestroyOneParams) bindID(rawData []string, hasKey bool, formats strfmt. // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("id", "path", "int64", raw) } diff --git a/tutorials/todo-list/server-complete/restapi/operations/todos/destroy_one_responses.go b/tutorials/todo-list/server-complete/restapi/operations/todos/destroy_one_responses.go index 2cfe7ca5..0e4cef10 100644 --- a/tutorials/todo-list/server-complete/restapi/operations/todos/destroy_one_responses.go +++ b/tutorials/todo-list/server-complete/restapi/operations/todos/destroy_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/tutorials/todo-list/server-complete/models" ) diff --git a/tutorials/todo-list/server-complete/restapi/operations/todos/destroy_one_urlbuilder.go b/tutorials/todo-list/server-complete/restapi/operations/todos/destroy_one_urlbuilder.go index fa4417ce..975fbefc 100644 --- a/tutorials/todo-list/server-complete/restapi/operations/todos/destroy_one_urlbuilder.go +++ b/tutorials/todo-list/server-complete/restapi/operations/todos/destroy_one_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // DestroyOneURL generates an URL for the destroy one operation @@ -41,7 +41,7 @@ func (o *DestroyOneURL) Build() (*url.URL, error) { var _path = "/{id}" - id := swag.FormatInt64(o.ID) + id := conv.FormatInteger(o.ID) if id != "" { _path = strings.ReplaceAll(_path, "{id}", id) } else { diff --git a/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos_parameters.go b/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos_parameters.go index 3472ad6f..8fbe147d 100644 --- a/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos_parameters.go +++ b/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos_parameters.go @@ -9,7 +9,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // NewFindTodosParams creates a new FindTodosParams object @@ -87,7 +87,7 @@ func (o *FindTodosParams) bindLimit(rawData []string, hasKey bool, formats strfm return nil } - value, err := swag.ConvertInt32(raw) + value, err := conv.ConvertInt32(raw) if err != nil { return errors.InvalidType("limit", "query", "int32", raw) } @@ -110,7 +110,7 @@ func (o *FindTodosParams) bindSince(rawData []string, hasKey bool, formats strfm return nil } - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("since", "query", "int64", raw) } diff --git a/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos_responses.go b/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos_responses.go index bec844a7..5a44b5d7 100644 --- a/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos_responses.go +++ b/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/tutorials/todo-list/server-complete/models" ) diff --git a/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos_urlbuilder.go b/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos_urlbuilder.go index 825eeb4e..5472135f 100644 --- a/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos_urlbuilder.go +++ b/tutorials/todo-list/server-complete/restapi/operations/todos/find_todos_urlbuilder.go @@ -7,7 +7,7 @@ import ( "net/url" golangswaggerpaths "path" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // FindTodosURL generates an URL for the find todos operation @@ -48,7 +48,7 @@ func (o *FindTodosURL) Build() (*url.URL, error) { var limitQ string if o.Limit != nil { - limitQ = swag.FormatInt32(*o.Limit) + limitQ = conv.FormatInteger(*o.Limit) } if limitQ != "" { qs.Set("limit", limitQ) @@ -56,7 +56,7 @@ func (o *FindTodosURL) Build() (*url.URL, error) { var sinceQ string if o.Since != nil { - sinceQ = swag.FormatInt64(*o.Since) + sinceQ = conv.FormatInteger(*o.Since) } if sinceQ != "" { qs.Set("since", sinceQ) diff --git a/tutorials/todo-list/server-complete/restapi/operations/todos/update_one_parameters.go b/tutorials/todo-list/server-complete/restapi/operations/todos/update_one_parameters.go index b1b895e5..0eb3779a 100644 --- a/tutorials/todo-list/server-complete/restapi/operations/todos/update_one_parameters.go +++ b/tutorials/todo-list/server-complete/restapi/operations/todos/update_one_parameters.go @@ -9,7 +9,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" "github.com/go-openapi/validate" "github.com/go-swagger/examples/tutorials/todo-list/server-complete/models" @@ -96,7 +96,7 @@ func (o *UpdateOneParams) bindID(rawData []string, hasKey bool, formats strfmt.R // Required: true // Parameter is provided by construction from the route - value, err := swag.ConvertInt64(raw) + value, err := conv.ConvertInt64(raw) if err != nil { return errors.InvalidType("id", "path", "int64", raw) } diff --git a/tutorials/todo-list/server-complete/restapi/operations/todos/update_one_responses.go b/tutorials/todo-list/server-complete/restapi/operations/todos/update_one_responses.go index 458ca9da..2a6f5d01 100644 --- a/tutorials/todo-list/server-complete/restapi/operations/todos/update_one_responses.go +++ b/tutorials/todo-list/server-complete/restapi/operations/todos/update_one_responses.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/go-openapi/runtime" - "github.com/go-swagger/examples/tutorials/todo-list/server-complete/models" ) diff --git a/tutorials/todo-list/server-complete/restapi/operations/todos/update_one_urlbuilder.go b/tutorials/todo-list/server-complete/restapi/operations/todos/update_one_urlbuilder.go index 745deca3..1eb25473 100644 --- a/tutorials/todo-list/server-complete/restapi/operations/todos/update_one_urlbuilder.go +++ b/tutorials/todo-list/server-complete/restapi/operations/todos/update_one_urlbuilder.go @@ -8,7 +8,7 @@ import ( golangswaggerpaths "path" "strings" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/conv" ) // UpdateOneURL generates an URL for the update one operation @@ -41,7 +41,7 @@ func (o *UpdateOneURL) Build() (*url.URL, error) { var _path = "/{id}" - id := swag.FormatInt64(o.ID) + id := conv.FormatInteger(o.ID) if id != "" { _path = strings.ReplaceAll(_path, "{id}", id) } else { diff --git a/tutorials/todo-list/server-complete/restapi/server.go b/tutorials/todo-list/server-complete/restapi/server.go index 53e73e85..375ca460 100644 --- a/tutorials/todo-list/server-complete/restapi/server.go +++ b/tutorials/todo-list/server-complete/restapi/server.go @@ -22,7 +22,7 @@ import ( "golang.org/x/net/netutil" "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" + "github.com/go-openapi/swag/netutils" "github.com/go-swagger/examples/tutorials/todo-list/server-complete/restapi/operations" ) @@ -368,7 +368,7 @@ func (s *Server) Listen() error { return err } - h, p, err := swag.SplitHostPort(listener.Addr().String()) + h, p, err := netutils.SplitHostPort(listener.Addr().String()) if err != nil { return err } @@ -383,7 +383,7 @@ func (s *Server) Listen() error { return err } - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + sh, sp, err := netutils.SplitHostPort(tlsListener.Addr().String()) if err != nil { return err }