Add missing swagger spec (#175)

* Add missing swagger spec

* More cleaning up of the swagger.yml and removing unused structs

* Add TaskWrapper
This commit is contained in:
Seif Lotfy سيف لطفي
2016-10-19 21:22:41 +02:00
committed by C Cirello
parent c95c0dd8f0
commit e85a31b715
6 changed files with 28 additions and 262 deletions

View File

@@ -1,34 +0,0 @@
package models
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/validate"
"github.com/go-openapi/errors"
)
type AppsWrapper struct {
Apps []*App `json:"apps"`
}
func (m *AppsWrapper) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateApps(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *AppsWrapper) validateApps(formats strfmt.Registry) error {
if err := validate.Required("apps", "body", m.Apps); err != nil {
return err
}
return nil
}

View File

@@ -1,48 +0,0 @@
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 (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
/*NewTasksWrapper new tasks wrapper
swagger:model NewTasksWrapper
*/
type NewTasksWrapper struct {
/* tasks
Required: true
*/
Tasks []*NewTask `json:"tasks"`
}
// Validate validates this new tasks wrapper
func (m *NewTasksWrapper) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateTasks(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *NewTasksWrapper) validateTasks(formats strfmt.Registry) error {
if err := validate.Required("tasks", "body", m.Tasks); err != nil {
return err
}
return nil
}

View File

@@ -1,36 +0,0 @@
package models
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/validate"
"github.com/go-openapi/errors"
)
type RoutesWrapper struct {
Cursor string `json:"cursor,omitempty"`
Error *ErrorBody `json:"error,omitempty"`
Routes []*Route `json:"routes"`
}
func (m *RoutesWrapper) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateRoutes(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *RoutesWrapper) validateRoutes(formats strfmt.Registry) error {
if err := validate.Required("routes", "body", m.Routes); err != nil {
return err
}
return nil
}

View File

@@ -1,50 +0,0 @@
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 (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
)
/*TaskWrapper task wrapper
swagger:model TaskWrapper
*/
type TaskWrapper struct {
/* task
Required: true
*/
Task *Task `json:"task"`
}
// Validate validates this task wrapper
func (m *TaskWrapper) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateTask(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *TaskWrapper) validateTask(formats strfmt.Registry) error {
if m.Task != nil {
if err := m.Task.Validate(formats); err != nil {
return err
}
}
return nil
}

View File

@@ -1,56 +0,0 @@
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 (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
/*TasksWrapper tasks wrapper
swagger:model TasksWrapper
*/
type TasksWrapper struct {
/* Used to paginate results. If this is returned, pass it into the same query again to get more results.
*/
Cursor string `json:"cursor,omitempty"`
/* error
*/
Error *ErrorBody `json:"error,omitempty"`
/* tasks
Required: true
*/
Tasks []*Task `json:"tasks"`
}
// Validate validates this tasks wrapper
func (m *TasksWrapper) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateTasks(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *TasksWrapper) validateTasks(formats strfmt.Registry) error {
if err := validate.Required("tasks", "body", m.Tasks); err != nil {
return err
}
return nil
}

View File

@@ -1,6 +1,6 @@
# This is the IronFunctions API spec
# If you make changes here, remember to run `go generate` in routeserver/ and
# tasker/ to make sure you use the changes.
# If you make changes here, remember to run `go generate` in api/models/ and
# api/server to make sure you use the changes.
swagger: '2.0'
info:
@@ -143,7 +143,7 @@ paths:
description: Array of routes to post.
required: true
schema:
$ref: '#/definitions/NewRoutesWrapper'
$ref: '#/definitions/RoutesWrapper'
responses:
201:
description: Route created
@@ -251,7 +251,7 @@ paths:
200:
description: Task information
schema:
$ref: '#/definitions/TasksWrapper'
$ref: '#/definitions/TaskWrapper'
default:
description: Unexpected error
schema:
@@ -329,7 +329,6 @@ definitions:
Task:
allOf:
- $ref: "#/definitions/NewTask"
- $ref: "#/definitions/IdStatus"
- type: object
properties:
group_name:
@@ -381,39 +380,6 @@ definitions:
additionalProperties:
type: string
NewTasksWrapper:
type: object
required:
- tasks
properties:
tasks:
type: array
items:
$ref: '#/definitions/NewTask'
TasksWrapper:
type: object
required:
- tasks
properties:
tasks:
type: array
items:
$ref: '#/definitions/Task'
cursor:
type: string
description: Used to paginate results. If this is returned, pass it into the same query again to get more results.
error:
$ref: '#/definitions/ErrorBody'
TaskWrapper:
type: object
required:
- task
properties:
task:
$ref: '#/definitions/Task'
ErrorBody:
type: object
properties:
@@ -429,3 +395,27 @@ definitions:
properties:
error:
$ref: '#/definitions/ErrorBody'
NewTask:
type: object
required:
- image
- priority
properties:
image:
type: string
description: Name of Docker image to use. This is optional and can be used to override the image defined at the group level.
payload:
type: string
# 256k
# maxLength breaks ruby generator too: https://github.com/iron-io/worker_ruby/blob/0aa9236ce5060af3f15758937712973f80dd54fe/lib/iron_titan/models/task.rb#L272
# maxLength: 268435456
description: Payload for the task. This is what you pass into each task to make it do something.
TaskWrapper:
type: object
required:
- task
properties:
task:
$ref: '#/definitions/Task'