mirror of
https://github.com/rjNemo/go-microservices-tuto
synced 2026-06-06 02:16:46 +00:00
generate client
This commit is contained in:
parent
270de58204
commit
74e358d7ee
18 changed files with 1671 additions and 21 deletions
112
client/client/product_client.go
Normal file
112
client/client/product_client.go
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package client
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime"
|
||||
httptransport "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/rjNemo/go-micro/client/client/products"
|
||||
)
|
||||
|
||||
// Default product HTTP client.
|
||||
var Default = NewHTTPClient(nil)
|
||||
|
||||
const (
|
||||
// DefaultHost is the default Host
|
||||
// found in Meta (info) section of spec file
|
||||
DefaultHost string = "localhost"
|
||||
// DefaultBasePath is the default BasePath
|
||||
// found in Meta (info) section of spec file
|
||||
DefaultBasePath string = "/"
|
||||
)
|
||||
|
||||
// DefaultSchemes are the default schemes found in Meta (info) section of spec file
|
||||
var DefaultSchemes = []string{"http"}
|
||||
|
||||
// NewHTTPClient creates a new product HTTP client.
|
||||
func NewHTTPClient(formats strfmt.Registry) *Product {
|
||||
return NewHTTPClientWithConfig(formats, nil)
|
||||
}
|
||||
|
||||
// NewHTTPClientWithConfig creates a new product HTTP client,
|
||||
// using a customizable transport config.
|
||||
func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *Product {
|
||||
// ensure nullable parameters have default
|
||||
if cfg == nil {
|
||||
cfg = DefaultTransportConfig()
|
||||
}
|
||||
|
||||
// create transport and client
|
||||
transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
|
||||
return New(transport, formats)
|
||||
}
|
||||
|
||||
// New creates a new product client
|
||||
func New(transport runtime.ClientTransport, formats strfmt.Registry) *Product {
|
||||
// ensure nullable parameters have default
|
||||
if formats == nil {
|
||||
formats = strfmt.Default
|
||||
}
|
||||
|
||||
cli := new(Product)
|
||||
cli.Transport = transport
|
||||
cli.Products = products.New(transport, formats)
|
||||
return cli
|
||||
}
|
||||
|
||||
// DefaultTransportConfig creates a TransportConfig with the
|
||||
// default settings taken from the meta section of the spec file.
|
||||
func DefaultTransportConfig() *TransportConfig {
|
||||
return &TransportConfig{
|
||||
Host: DefaultHost,
|
||||
BasePath: DefaultBasePath,
|
||||
Schemes: DefaultSchemes,
|
||||
}
|
||||
}
|
||||
|
||||
// TransportConfig contains the transport related info,
|
||||
// found in the meta section of the spec file.
|
||||
type TransportConfig struct {
|
||||
Host string
|
||||
BasePath string
|
||||
Schemes []string
|
||||
}
|
||||
|
||||
// WithHost overrides the default host,
|
||||
// provided by the meta section of the spec file.
|
||||
func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
|
||||
cfg.Host = host
|
||||
return cfg
|
||||
}
|
||||
|
||||
// WithBasePath overrides the default basePath,
|
||||
// provided by the meta section of the spec file.
|
||||
func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
|
||||
cfg.BasePath = basePath
|
||||
return cfg
|
||||
}
|
||||
|
||||
// WithSchemes overrides the default schemes,
|
||||
// provided by the meta section of the spec file.
|
||||
func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
|
||||
cfg.Schemes = schemes
|
||||
return cfg
|
||||
}
|
||||
|
||||
// Product is a client for product
|
||||
type Product struct {
|
||||
Products products.ClientService
|
||||
|
||||
Transport runtime.ClientTransport
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client and all its subresources
|
||||
func (c *Product) SetTransport(transport runtime.ClientTransport) {
|
||||
c.Transport = transport
|
||||
c.Products.SetTransport(transport)
|
||||
}
|
||||
112
client/client/products/create_product_parameters.go
Normal file
112
client/client/products/create_product_parameters.go
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package products
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewCreateProductParams creates a new CreateProductParams object
|
||||
// with the default values initialized.
|
||||
func NewCreateProductParams() *CreateProductParams {
|
||||
|
||||
return &CreateProductParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateProductParamsWithTimeout creates a new CreateProductParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
func NewCreateProductParamsWithTimeout(timeout time.Duration) *CreateProductParams {
|
||||
|
||||
return &CreateProductParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateProductParamsWithContext creates a new CreateProductParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
func NewCreateProductParamsWithContext(ctx context.Context) *CreateProductParams {
|
||||
|
||||
return &CreateProductParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateProductParamsWithHTTPClient creates a new CreateProductParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
func NewCreateProductParamsWithHTTPClient(client *http.Client) *CreateProductParams {
|
||||
|
||||
return &CreateProductParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*CreateProductParams contains all the parameters to send to the API endpoint
|
||||
for the create product operation typically these are written to a http.Request
|
||||
*/
|
||||
type CreateProductParams struct {
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the create product params
|
||||
func (o *CreateProductParams) WithTimeout(timeout time.Duration) *CreateProductParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the create product params
|
||||
func (o *CreateProductParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the create product params
|
||||
func (o *CreateProductParams) WithContext(ctx context.Context) *CreateProductParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the create product params
|
||||
func (o *CreateProductParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the create product params
|
||||
func (o *CreateProductParams) WithHTTPClient(client *http.Client) *CreateProductParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the create product params
|
||||
func (o *CreateProductParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *CreateProductParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
123
client/client/products/create_product_responses.go
Normal file
123
client/client/products/create_product_responses.go
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package products
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/rjNemo/go-micro/client/models"
|
||||
)
|
||||
|
||||
// CreateProductReader is a Reader for the CreateProduct structure.
|
||||
type CreateProductReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *CreateProductReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewCreateProductOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 422:
|
||||
result := NewCreateProductUnprocessableEntity()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 501:
|
||||
result := NewCreateProductNotImplemented()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
|
||||
default:
|
||||
return nil, runtime.NewAPIError("unknown error", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateProductOK creates a CreateProductOK with default headers values
|
||||
func NewCreateProductOK() *CreateProductOK {
|
||||
return &CreateProductOK{}
|
||||
}
|
||||
|
||||
/*CreateProductOK handles this case with default header values.
|
||||
|
||||
product in the response.
|
||||
*/
|
||||
type CreateProductOK struct {
|
||||
Payload *models.Product
|
||||
}
|
||||
|
||||
func (o *CreateProductOK) Error() string {
|
||||
return fmt.Sprintf("[POST /products][%d] createProductOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *CreateProductOK) GetPayload() *models.Product {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *CreateProductOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.Product)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewCreateProductUnprocessableEntity creates a CreateProductUnprocessableEntity with default headers values
|
||||
func NewCreateProductUnprocessableEntity() *CreateProductUnprocessableEntity {
|
||||
return &CreateProductUnprocessableEntity{}
|
||||
}
|
||||
|
||||
/*CreateProductUnprocessableEntity handles this case with default header values.
|
||||
|
||||
Validation errors defined as an array of strings
|
||||
*/
|
||||
type CreateProductUnprocessableEntity struct {
|
||||
}
|
||||
|
||||
func (o *CreateProductUnprocessableEntity) Error() string {
|
||||
return fmt.Sprintf("[POST /products][%d] createProductUnprocessableEntity ", 422)
|
||||
}
|
||||
|
||||
func (o *CreateProductUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewCreateProductNotImplemented creates a CreateProductNotImplemented with default headers values
|
||||
func NewCreateProductNotImplemented() *CreateProductNotImplemented {
|
||||
return &CreateProductNotImplemented{}
|
||||
}
|
||||
|
||||
/*CreateProductNotImplemented handles this case with default header values.
|
||||
|
||||
Generic error message returned as a string
|
||||
*/
|
||||
type CreateProductNotImplemented struct {
|
||||
}
|
||||
|
||||
func (o *CreateProductNotImplemented) Error() string {
|
||||
return fmt.Sprintf("[POST /products][%d] createProductNotImplemented ", 501)
|
||||
}
|
||||
|
||||
func (o *CreateProductNotImplemented) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
136
client/client/products/delete_product_parameters.go
Normal file
136
client/client/products/delete_product_parameters.go
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package products
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// NewDeleteProductParams creates a new DeleteProductParams object
|
||||
// with the default values initialized.
|
||||
func NewDeleteProductParams() *DeleteProductParams {
|
||||
var ()
|
||||
return &DeleteProductParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteProductParamsWithTimeout creates a new DeleteProductParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
func NewDeleteProductParamsWithTimeout(timeout time.Duration) *DeleteProductParams {
|
||||
var ()
|
||||
return &DeleteProductParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteProductParamsWithContext creates a new DeleteProductParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
func NewDeleteProductParamsWithContext(ctx context.Context) *DeleteProductParams {
|
||||
var ()
|
||||
return &DeleteProductParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteProductParamsWithHTTPClient creates a new DeleteProductParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
func NewDeleteProductParamsWithHTTPClient(client *http.Client) *DeleteProductParams {
|
||||
var ()
|
||||
return &DeleteProductParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*DeleteProductParams contains all the parameters to send to the API endpoint
|
||||
for the delete product operation typically these are written to a http.Request
|
||||
*/
|
||||
type DeleteProductParams struct {
|
||||
|
||||
/*ID
|
||||
The ID of a product in the database
|
||||
|
||||
*/
|
||||
ID int64
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the delete product params
|
||||
func (o *DeleteProductParams) WithTimeout(timeout time.Duration) *DeleteProductParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the delete product params
|
||||
func (o *DeleteProductParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the delete product params
|
||||
func (o *DeleteProductParams) WithContext(ctx context.Context) *DeleteProductParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the delete product params
|
||||
func (o *DeleteProductParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the delete product params
|
||||
func (o *DeleteProductParams) WithHTTPClient(client *http.Client) *DeleteProductParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the delete product params
|
||||
func (o *DeleteProductParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the delete product params
|
||||
func (o *DeleteProductParams) WithID(id int64) *DeleteProductParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the delete product params
|
||||
func (o *DeleteProductParams) SetID(id int64) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *DeleteProductParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
108
client/client/products/delete_product_responses.go
Normal file
108
client/client/products/delete_product_responses.go
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package products
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// DeleteProductReader is a Reader for the DeleteProduct structure.
|
||||
type DeleteProductReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *DeleteProductReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 204:
|
||||
result := NewDeleteProductNoContent()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 404:
|
||||
result := NewDeleteProductNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 501:
|
||||
result := NewDeleteProductNotImplemented()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
|
||||
default:
|
||||
return nil, runtime.NewAPIError("unknown error", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteProductNoContent creates a DeleteProductNoContent with default headers values
|
||||
func NewDeleteProductNoContent() *DeleteProductNoContent {
|
||||
return &DeleteProductNoContent{}
|
||||
}
|
||||
|
||||
/*DeleteProductNoContent handles this case with default header values.
|
||||
|
||||
empty response
|
||||
*/
|
||||
type DeleteProductNoContent struct {
|
||||
}
|
||||
|
||||
func (o *DeleteProductNoContent) Error() string {
|
||||
return fmt.Sprintf("[DELETE /products/{id}][%d] deleteProductNoContent ", 204)
|
||||
}
|
||||
|
||||
func (o *DeleteProductNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteProductNotFound creates a DeleteProductNotFound with default headers values
|
||||
func NewDeleteProductNotFound() *DeleteProductNotFound {
|
||||
return &DeleteProductNotFound{}
|
||||
}
|
||||
|
||||
/*DeleteProductNotFound handles this case with default header values.
|
||||
|
||||
Generic error message returned as a string
|
||||
*/
|
||||
type DeleteProductNotFound struct {
|
||||
}
|
||||
|
||||
func (o *DeleteProductNotFound) Error() string {
|
||||
return fmt.Sprintf("[DELETE /products/{id}][%d] deleteProductNotFound ", 404)
|
||||
}
|
||||
|
||||
func (o *DeleteProductNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteProductNotImplemented creates a DeleteProductNotImplemented with default headers values
|
||||
func NewDeleteProductNotImplemented() *DeleteProductNotImplemented {
|
||||
return &DeleteProductNotImplemented{}
|
||||
}
|
||||
|
||||
/*DeleteProductNotImplemented handles this case with default header values.
|
||||
|
||||
Generic error message returned as a string
|
||||
*/
|
||||
type DeleteProductNotImplemented struct {
|
||||
}
|
||||
|
||||
func (o *DeleteProductNotImplemented) Error() string {
|
||||
return fmt.Sprintf("[DELETE /products/{id}][%d] deleteProductNotImplemented ", 501)
|
||||
}
|
||||
|
||||
func (o *DeleteProductNotImplemented) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
136
client/client/products/get_product_parameters.go
Normal file
136
client/client/products/get_product_parameters.go
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package products
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// NewGetProductParams creates a new GetProductParams object
|
||||
// with the default values initialized.
|
||||
func NewGetProductParams() *GetProductParams {
|
||||
var ()
|
||||
return &GetProductParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetProductParamsWithTimeout creates a new GetProductParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
func NewGetProductParamsWithTimeout(timeout time.Duration) *GetProductParams {
|
||||
var ()
|
||||
return &GetProductParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetProductParamsWithContext creates a new GetProductParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
func NewGetProductParamsWithContext(ctx context.Context) *GetProductParams {
|
||||
var ()
|
||||
return &GetProductParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetProductParamsWithHTTPClient creates a new GetProductParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
func NewGetProductParamsWithHTTPClient(client *http.Client) *GetProductParams {
|
||||
var ()
|
||||
return &GetProductParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*GetProductParams contains all the parameters to send to the API endpoint
|
||||
for the get product operation typically these are written to a http.Request
|
||||
*/
|
||||
type GetProductParams struct {
|
||||
|
||||
/*ID
|
||||
The ID of a product in the database
|
||||
|
||||
*/
|
||||
ID int64
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the get product params
|
||||
func (o *GetProductParams) WithTimeout(timeout time.Duration) *GetProductParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the get product params
|
||||
func (o *GetProductParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the get product params
|
||||
func (o *GetProductParams) WithContext(ctx context.Context) *GetProductParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the get product params
|
||||
func (o *GetProductParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the get product params
|
||||
func (o *GetProductParams) WithHTTPClient(client *http.Client) *GetProductParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the get product params
|
||||
func (o *GetProductParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the get product params
|
||||
func (o *GetProductParams) WithID(id int64) *GetProductParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the get product params
|
||||
func (o *GetProductParams) SetID(id int64) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *GetProductParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
96
client/client/products/get_product_responses.go
Normal file
96
client/client/products/get_product_responses.go
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package products
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/rjNemo/go-micro/client/models"
|
||||
)
|
||||
|
||||
// GetProductReader is a Reader for the GetProduct structure.
|
||||
type GetProductReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *GetProductReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewGetProductOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 404:
|
||||
result := NewGetProductNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
|
||||
default:
|
||||
return nil, runtime.NewAPIError("unknown error", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetProductOK creates a GetProductOK with default headers values
|
||||
func NewGetProductOK() *GetProductOK {
|
||||
return &GetProductOK{}
|
||||
}
|
||||
|
||||
/*GetProductOK handles this case with default header values.
|
||||
|
||||
product in the response.
|
||||
*/
|
||||
type GetProductOK struct {
|
||||
Payload *models.Product
|
||||
}
|
||||
|
||||
func (o *GetProductOK) Error() string {
|
||||
return fmt.Sprintf("[GET /products/{id}][%d] getProductOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetProductOK) GetPayload() *models.Product {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetProductOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.Product)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewGetProductNotFound creates a GetProductNotFound with default headers values
|
||||
func NewGetProductNotFound() *GetProductNotFound {
|
||||
return &GetProductNotFound{}
|
||||
}
|
||||
|
||||
/*GetProductNotFound handles this case with default header values.
|
||||
|
||||
Generic error message returned as a string
|
||||
*/
|
||||
type GetProductNotFound struct {
|
||||
}
|
||||
|
||||
func (o *GetProductNotFound) Error() string {
|
||||
return fmt.Sprintf("[GET /products/{id}][%d] getProductNotFound ", 404)
|
||||
}
|
||||
|
||||
func (o *GetProductNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
112
client/client/products/list_products_parameters.go
Normal file
112
client/client/products/list_products_parameters.go
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package products
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewListProductsParams creates a new ListProductsParams object
|
||||
// with the default values initialized.
|
||||
func NewListProductsParams() *ListProductsParams {
|
||||
|
||||
return &ListProductsParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListProductsParamsWithTimeout creates a new ListProductsParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
func NewListProductsParamsWithTimeout(timeout time.Duration) *ListProductsParams {
|
||||
|
||||
return &ListProductsParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListProductsParamsWithContext creates a new ListProductsParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
func NewListProductsParamsWithContext(ctx context.Context) *ListProductsParams {
|
||||
|
||||
return &ListProductsParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewListProductsParamsWithHTTPClient creates a new ListProductsParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
func NewListProductsParamsWithHTTPClient(client *http.Client) *ListProductsParams {
|
||||
|
||||
return &ListProductsParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*ListProductsParams contains all the parameters to send to the API endpoint
|
||||
for the list products operation typically these are written to a http.Request
|
||||
*/
|
||||
type ListProductsParams struct {
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the list products params
|
||||
func (o *ListProductsParams) WithTimeout(timeout time.Duration) *ListProductsParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the list products params
|
||||
func (o *ListProductsParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the list products params
|
||||
func (o *ListProductsParams) WithContext(ctx context.Context) *ListProductsParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the list products params
|
||||
func (o *ListProductsParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the list products params
|
||||
func (o *ListProductsParams) WithHTTPClient(client *http.Client) *ListProductsParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the list products params
|
||||
func (o *ListProductsParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *ListProductsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
67
client/client/products/list_products_responses.go
Normal file
67
client/client/products/list_products_responses.go
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package products
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/rjNemo/go-micro/client/models"
|
||||
)
|
||||
|
||||
// ListProductsReader is a Reader for the ListProducts structure.
|
||||
type ListProductsReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *ListProductsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewListProductsOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
|
||||
default:
|
||||
return nil, runtime.NewAPIError("unknown error", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewListProductsOK creates a ListProductsOK with default headers values
|
||||
func NewListProductsOK() *ListProductsOK {
|
||||
return &ListProductsOK{}
|
||||
}
|
||||
|
||||
/*ListProductsOK handles this case with default header values.
|
||||
|
||||
list of products in the response.
|
||||
*/
|
||||
type ListProductsOK struct {
|
||||
Payload []*models.Product
|
||||
}
|
||||
|
||||
func (o *ListProductsOK) Error() string {
|
||||
return fmt.Sprintf("[GET /products][%d] listProductsOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *ListProductsOK) GetPayload() []*models.Product {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ListProductsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
216
client/client/products/products_client.go
Normal file
216
client/client/products/products_client.go
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package products
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// New creates a new products API client.
|
||||
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
|
||||
return &Client{transport: transport, formats: formats}
|
||||
}
|
||||
|
||||
/*
|
||||
Client for products API
|
||||
*/
|
||||
type Client struct {
|
||||
transport runtime.ClientTransport
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ClientService is the interface for Client methods
|
||||
type ClientService interface {
|
||||
CreateProduct(params *CreateProductParams) (*CreateProductOK, error)
|
||||
|
||||
DeleteProduct(params *DeleteProductParams) (*DeleteProductNoContent, error)
|
||||
|
||||
GetProduct(params *GetProductParams) (*GetProductOK, error)
|
||||
|
||||
ListProducts(params *ListProductsParams) (*ListProductsOK, error)
|
||||
|
||||
UpdateProduct(params *UpdateProductParams) (*UpdateProductNoContent, error)
|
||||
|
||||
SetTransport(transport runtime.ClientTransport)
|
||||
}
|
||||
|
||||
/*
|
||||
CreateProduct Create a new product
|
||||
*/
|
||||
func (a *Client) CreateProduct(params *CreateProductParams) (*CreateProductOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewCreateProductParams()
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(&runtime.ClientOperation{
|
||||
ID: "createProduct",
|
||||
Method: "POST",
|
||||
PathPattern: "/products",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &CreateProductReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*CreateProductOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for createProduct: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteProduct Update a products details
|
||||
*/
|
||||
func (a *Client) DeleteProduct(params *DeleteProductParams) (*DeleteProductNoContent, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewDeleteProductParams()
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(&runtime.ClientOperation{
|
||||
ID: "deleteProduct",
|
||||
Method: "DELETE",
|
||||
PathPattern: "/products/{id}",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &DeleteProductReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*DeleteProductNoContent)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for deleteProduct: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
GetProduct Return a list of products from the database
|
||||
*/
|
||||
func (a *Client) GetProduct(params *GetProductParams) (*GetProductOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewGetProductParams()
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(&runtime.ClientOperation{
|
||||
ID: "getProduct",
|
||||
Method: "GET",
|
||||
PathPattern: "/products/{id}",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &GetProductReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*GetProductOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for getProduct: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
ListProducts Return a list of products from the database
|
||||
*/
|
||||
func (a *Client) ListProducts(params *ListProductsParams) (*ListProductsOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewListProductsParams()
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(&runtime.ClientOperation{
|
||||
ID: "listProducts",
|
||||
Method: "GET",
|
||||
PathPattern: "/products",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &ListProductsReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*ListProductsOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for listProducts: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
UpdateProduct Update a products details
|
||||
*/
|
||||
func (a *Client) UpdateProduct(params *UpdateProductParams) (*UpdateProductNoContent, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewUpdateProductParams()
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(&runtime.ClientOperation{
|
||||
ID: "updateProduct",
|
||||
Method: "PUT",
|
||||
PathPattern: "/products/{id}",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &UpdateProductReader{formats: a.formats},
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*UpdateProductNoContent)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
||||
msg := fmt.Sprintf("unexpected success response for updateProduct: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client
|
||||
func (a *Client) SetTransport(transport runtime.ClientTransport) {
|
||||
a.transport = transport
|
||||
}
|
||||
136
client/client/products/update_product_parameters.go
Normal file
136
client/client/products/update_product_parameters.go
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package products
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// NewUpdateProductParams creates a new UpdateProductParams object
|
||||
// with the default values initialized.
|
||||
func NewUpdateProductParams() *UpdateProductParams {
|
||||
var ()
|
||||
return &UpdateProductParams{
|
||||
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateProductParamsWithTimeout creates a new UpdateProductParams object
|
||||
// with the default values initialized, and the ability to set a timeout on a request
|
||||
func NewUpdateProductParamsWithTimeout(timeout time.Duration) *UpdateProductParams {
|
||||
var ()
|
||||
return &UpdateProductParams{
|
||||
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateProductParamsWithContext creates a new UpdateProductParams object
|
||||
// with the default values initialized, and the ability to set a context for a request
|
||||
func NewUpdateProductParamsWithContext(ctx context.Context) *UpdateProductParams {
|
||||
var ()
|
||||
return &UpdateProductParams{
|
||||
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateProductParamsWithHTTPClient creates a new UpdateProductParams object
|
||||
// with the default values initialized, and the ability to set a custom HTTPClient for a request
|
||||
func NewUpdateProductParamsWithHTTPClient(client *http.Client) *UpdateProductParams {
|
||||
var ()
|
||||
return &UpdateProductParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*UpdateProductParams contains all the parameters to send to the API endpoint
|
||||
for the update product operation typically these are written to a http.Request
|
||||
*/
|
||||
type UpdateProductParams struct {
|
||||
|
||||
/*ID
|
||||
The ID of a product in the database
|
||||
|
||||
*/
|
||||
ID int64
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the update product params
|
||||
func (o *UpdateProductParams) WithTimeout(timeout time.Duration) *UpdateProductParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the update product params
|
||||
func (o *UpdateProductParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the update product params
|
||||
func (o *UpdateProductParams) WithContext(ctx context.Context) *UpdateProductParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the update product params
|
||||
func (o *UpdateProductParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the update product params
|
||||
func (o *UpdateProductParams) WithHTTPClient(client *http.Client) *UpdateProductParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the update product params
|
||||
func (o *UpdateProductParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithID adds the id to the update product params
|
||||
func (o *UpdateProductParams) WithID(id int64) *UpdateProductParams {
|
||||
o.SetID(id)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetID adds the id to the update product params
|
||||
func (o *UpdateProductParams) SetID(id int64) {
|
||||
o.ID = id
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *UpdateProductParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param id
|
||||
if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
108
client/client/products/update_product_responses.go
Normal file
108
client/client/products/update_product_responses.go
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package products
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// UpdateProductReader is a Reader for the UpdateProduct structure.
|
||||
type UpdateProductReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *UpdateProductReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 204:
|
||||
result := NewUpdateProductNoContent()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 404:
|
||||
result := NewUpdateProductNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 422:
|
||||
result := NewUpdateProductUnprocessableEntity()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
|
||||
default:
|
||||
return nil, runtime.NewAPIError("unknown error", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateProductNoContent creates a UpdateProductNoContent with default headers values
|
||||
func NewUpdateProductNoContent() *UpdateProductNoContent {
|
||||
return &UpdateProductNoContent{}
|
||||
}
|
||||
|
||||
/*UpdateProductNoContent handles this case with default header values.
|
||||
|
||||
empty response
|
||||
*/
|
||||
type UpdateProductNoContent struct {
|
||||
}
|
||||
|
||||
func (o *UpdateProductNoContent) Error() string {
|
||||
return fmt.Sprintf("[PUT /products/{id}][%d] updateProductNoContent ", 204)
|
||||
}
|
||||
|
||||
func (o *UpdateProductNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewUpdateProductNotFound creates a UpdateProductNotFound with default headers values
|
||||
func NewUpdateProductNotFound() *UpdateProductNotFound {
|
||||
return &UpdateProductNotFound{}
|
||||
}
|
||||
|
||||
/*UpdateProductNotFound handles this case with default header values.
|
||||
|
||||
Generic error message returned as a string
|
||||
*/
|
||||
type UpdateProductNotFound struct {
|
||||
}
|
||||
|
||||
func (o *UpdateProductNotFound) Error() string {
|
||||
return fmt.Sprintf("[PUT /products/{id}][%d] updateProductNotFound ", 404)
|
||||
}
|
||||
|
||||
func (o *UpdateProductNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewUpdateProductUnprocessableEntity creates a UpdateProductUnprocessableEntity with default headers values
|
||||
func NewUpdateProductUnprocessableEntity() *UpdateProductUnprocessableEntity {
|
||||
return &UpdateProductUnprocessableEntity{}
|
||||
}
|
||||
|
||||
/*UpdateProductUnprocessableEntity handles this case with default header values.
|
||||
|
||||
Validation errors defined as an array of strings
|
||||
*/
|
||||
type UpdateProductUnprocessableEntity struct {
|
||||
}
|
||||
|
||||
func (o *UpdateProductUnprocessableEntity) Error() string {
|
||||
return fmt.Sprintf("[PUT /products/{id}][%d] updateProductUnprocessableEntity ", 422)
|
||||
}
|
||||
|
||||
func (o *UpdateProductUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
19
client/client_test.go
Normal file
19
client/client_test.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/rjNemo/go-micro/client/client"
|
||||
"github.com/rjNemo/go-micro/client/client/products"
|
||||
)
|
||||
|
||||
func TestOurClient(t *testing.T) {
|
||||
conf := client.DefaultTransportConfig().WithHost("localhost:5000")
|
||||
c := client.NewHTTPClientWithConfig(nil, conf)
|
||||
prod, err := c.Products.ListProducts(products.NewListProductsParams())
|
||||
if err != nil {
|
||||
t.Fatalf("%v", err)
|
||||
}
|
||||
fmt.Printf("%#v", prod.GetPayload()[0])
|
||||
}
|
||||
156
client/models/product.go
Normal file
156
client/models/product.go
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
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 (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// Product Product defines the structure of a product
|
||||
//
|
||||
// swagger:model Product
|
||||
type Product struct {
|
||||
|
||||
// the description for this poduct
|
||||
// Max Length: 10000
|
||||
Description string `json:"description,omitempty"`
|
||||
|
||||
// the id for this product
|
||||
// Required: true
|
||||
// Minimum: 1
|
||||
ID *int64 `json:"id"`
|
||||
|
||||
// the name for this poduct
|
||||
// Required: true
|
||||
// Max Length: 255
|
||||
Name *string `json:"name"`
|
||||
|
||||
// the price for the product
|
||||
// Required: true
|
||||
// Minimum: 0.01
|
||||
Price *float32 `json:"price"`
|
||||
|
||||
// the SKU for the product
|
||||
// Required: true
|
||||
// Pattern: [a-z]+-[a-z]+-[a-z]+
|
||||
SKU *string `json:"sku"`
|
||||
}
|
||||
|
||||
// Validate validates this product
|
||||
func (m *Product) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateDescription(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateID(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateName(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validatePrice(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateSKU(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Product) validateDescription(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Description) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validate.MaxLength("description", "body", string(m.Description), 10000); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Product) validateID(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("id", "body", m.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.MinimumInt("id", "body", int64(*m.ID), 1, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Product) validateName(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("name", "body", m.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.MaxLength("name", "body", string(*m.Name), 255); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Product) validatePrice(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("price", "body", m.Price); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.Minimum("price", "body", float64(*m.Price), 0.01, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Product) validateSKU(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("sku", "body", m.SKU); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.Pattern("sku", "body", string(*m.SKU), `[a-z]+-[a-z]+-[a-z]+`); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *Product) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *Product) UnmarshalBinary(b []byte) error {
|
||||
var res Product
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
4
go.mod
4
go.mod
|
|
@ -3,7 +3,11 @@ module github.com/rjNemo/go-micro
|
|||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/go-openapi/errors v0.19.6
|
||||
github.com/go-openapi/runtime v0.19.19
|
||||
github.com/go-openapi/strfmt v0.19.5
|
||||
github.com/go-openapi/swag v0.19.9
|
||||
github.com/go-openapi/validate v0.19.10
|
||||
github.com/go-playground/universal-translator v0.17.0 // indirect
|
||||
github.com/go-playground/validator v9.31.0+incompatible
|
||||
github.com/gorilla/mux v1.7.4
|
||||
|
|
|
|||
9
go.sum
9
go.sum
|
|
@ -12,6 +12,7 @@ github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535/go.mod h1:o
|
|||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/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.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
|
|
@ -115,8 +116,10 @@ github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/V
|
|||
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
|
||||
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
|
|
@ -132,6 +135,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
|||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
|
|
@ -147,6 +151,7 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh
|
|||
github.com/mitchellh/mapstructure v1.3.2 h1:mRS76wmkOn3KkKAyXDu42V+6ebnXWIztFSYGN7GeoRg=
|
||||
github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||
github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo=
|
||||
|
|
@ -169,7 +174,9 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
|
|||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
|
||||
github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
|
||||
|
|
@ -228,6 +235,7 @@ golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgw
|
|||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
|
||||
|
|
@ -241,4 +249,5 @@ gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
|||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/rjNemo/go-micro/products/models"
|
||||
)
|
||||
|
||||
// swagger:route PUT /products products updateProduct
|
||||
// swagger:route PUT /products/{id} products updateProduct
|
||||
// Update a products details
|
||||
//
|
||||
// responses:
|
||||
|
|
|
|||
40
swagger.yaml
40
swagger.yaml
|
|
@ -65,26 +65,6 @@ paths:
|
|||
$ref: '#/responses/errorResponse'
|
||||
tags:
|
||||
- products
|
||||
put:
|
||||
description: Update a products details
|
||||
operationId: updateProduct
|
||||
parameters:
|
||||
- description: The ID of a product in the database
|
||||
format: int64
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
x-go-name: ID
|
||||
responses:
|
||||
"204":
|
||||
$ref: '#/responses/noContent'
|
||||
"404":
|
||||
$ref: '#/responses/errorResponse'
|
||||
"422":
|
||||
$ref: '#/responses/errorValidation'
|
||||
tags:
|
||||
- products
|
||||
/products/{id}:
|
||||
delete:
|
||||
description: Update a products details
|
||||
|
|
@ -124,6 +104,26 @@ paths:
|
|||
$ref: '#/responses/errorResponse'
|
||||
tags:
|
||||
- products
|
||||
put:
|
||||
description: Update a products details
|
||||
operationId: updateProduct
|
||||
parameters:
|
||||
- description: The ID of a product in the database
|
||||
format: int64
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
x-go-name: ID
|
||||
responses:
|
||||
"204":
|
||||
$ref: '#/responses/noContent'
|
||||
"404":
|
||||
$ref: '#/responses/errorResponse'
|
||||
"422":
|
||||
$ref: '#/responses/errorValidation'
|
||||
tags:
|
||||
- products
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
|
|
|
|||
Loading…
Reference in a new issue