summaryrefslogtreecommitdiff
path: root/err_response.go
diff options
context:
space:
mode:
authorAlexander Mazuruk <a.mazuruk@samsung.com>2018-02-21 11:08:06 +0100
committerAlexander Mazuruk <a.mazuruk@samsung.com>2018-07-20 17:07:33 +0200
commit123eec4f66b4dbfbcceb4ad2f1fb35c44c6cddb0 (patch)
tree0ef64eaff9b780de67aacf1cee90a2e475e26461 /err_response.go
parent28edc0bd2eaf071653b82bfcc6ef843dc8256aea (diff)
downloadweles-123eec4f66b4dbfbcceb4ad2f1fb35c44c6cddb0.tar.gz
weles-123eec4f66b4dbfbcceb4ad2f1fb35c44c6cddb0.tar.bz2
weles-123eec4f66b4dbfbcceb4ad2f1fb35c44c6cddb0.zip
Add initial swagger server
Swagger was chosen due to: - Easy generation of server and client boilerplate code in many languages. (in Weles project only golang is used but the swagger.yml file can be used to generate Weles server/client boilerplate in any language) - Clear, automatically generated documentation - Promising standard that this tool is based on: https://github.com/OAI/OpenAPI-Specification This commit should be treated as the Weles server "scaffolding" The initial swagger.yml file is added so there is something to generate the server from. "tbd" will be removed in future commits. Server was generated using following command: ./dev-tools/swagger generate server \ -A weles \ -f ./swagger.yml \ -m ../weles \ -s ./server \ -r ./COPYING \ --flag-strategy pflag \ --compatibility-mode=modern Due to agreed name of the server package ("server") there was a conflict in names in generated code causng build error. Generated code used server as a name for an object instance which has been renamed to srv. The Makefile recipe has additional --exclude-main flag which prevents the swagger generator from overwriting cmd/weles-server/main.go This flag must be set because: - obviously as stated above regenerating main will cause build error - all Weles objects will have to be created there - additional Weles flags will have to be added there Thus overwriting this file is a no-no and server regeneration should only be performed using provided Makefile recipe. The Makefile has also a recipe to generate html documentation which is intended to be integrated with Sphinx documentation. This recipe requires docker: https://docs.docker.com/get-started/ --- Verification Update your vendor directory $ make vendor To build server: $ make server You can check default swagger generated server flags: $ bin/weles-server --help When the server is running you can also see how the automatically served swagger documentation looks like: http://{host:port}/docs host and port are flags that should be supplied when running Weles. If not provided, localhost and random port will be used. To regenerate swagger server code: $ make swagger-server-generate To generate html documentation: $ make swagger-docs-html Change-Id: I00cda82219944cc6ab1937f6d14f05d52c7fd4e5 Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
Diffstat (limited to 'err_response.go')
-rw-r--r--err_response.go61
1 files changed, 61 insertions, 0 deletions
diff --git a/err_response.go b/err_response.go
new file mode 100644
index 0000000..1220654
--- /dev/null
+++ b/err_response.go
@@ -0,0 +1,61 @@
+// Code generated by go-swagger; DO NOT EDIT.
+
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License
+//
+
+package weles
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ strfmt "github.com/go-openapi/strfmt"
+
+ "github.com/go-openapi/swag"
+)
+
+// ErrResponse is a standard error response containing information about the error. It consists of error type and message.
+// swagger:model ErrResponse
+type ErrResponse struct {
+
+ // message
+ Message string `json:"message,omitempty"`
+
+ // type
+ Type string `json:"type,omitempty"`
+}
+
+// Validate validates this err response
+func (m *ErrResponse) Validate(formats strfmt.Registry) error {
+ return nil
+}
+
+// MarshalBinary interface implementation
+func (m *ErrResponse) MarshalBinary() ([]byte, error) {
+ if m == nil {
+ return nil, nil
+ }
+ return swag.WriteJSON(m)
+}
+
+// UnmarshalBinary interface implementation
+func (m *ErrResponse) UnmarshalBinary(b []byte) error {
+ var res ErrResponse
+ if err := swag.ReadJSON(b, &res); err != nil {
+ return err
+ }
+ *m = res
+ return nil
+}