Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
ff2fcd43
Commit
ff2fcd43
authored
Jul 25, 2015
by
Anastasis Andronidis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added SwaggerDoc() in api-server
parent
9f21ae21
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
api_installer.go
pkg/apiserver/api_installer.go
+10
-1
apiserver_test.go
pkg/apiserver/apiserver_test.go
+9
-2
No files found.
pkg/apiserver/api_installer.go
View file @
ff2fcd43
...
@@ -52,6 +52,11 @@ type action struct {
...
@@ -52,6 +52,11 @@ type action struct {
Namer
ScopeNamer
Namer
ScopeNamer
}
}
// An interface to see if an object supports swagger documentation as a method
type
documentable
interface
{
SwaggerDoc
()
map
[
string
]
string
}
// errEmptyName is returned when API requests do not fill the name section of the path.
// errEmptyName is returned when API requests do not fill the name section of the path.
var
errEmptyName
=
errors
.
NewBadRequest
(
"name must be provided"
)
var
errEmptyName
=
errors
.
NewBadRequest
(
"name must be provided"
)
...
@@ -796,7 +801,11 @@ func addObjectParams(ws *restful.WebService, route *restful.RouteBuilder, obj in
...
@@ -796,7 +801,11 @@ func addObjectParams(ws *restful.WebService, route *restful.RouteBuilder, obj in
if
len
(
jsonName
)
==
0
{
if
len
(
jsonName
)
==
0
{
continue
continue
}
}
desc
:=
sf
.
Tag
.
Get
(
"description"
)
var
desc
string
if
docable
,
ok
:=
obj
.
(
documentable
);
ok
{
desc
=
docable
.
SwaggerDoc
()[
jsonName
]
}
route
.
Param
(
ws
.
QueryParameter
(
jsonName
,
desc
)
.
DataType
(
typeToJSON
(
sf
.
Type
.
Name
())))
route
.
Param
(
ws
.
QueryParameter
(
jsonName
,
desc
)
.
DataType
(
typeToJSON
(
sf
.
Type
.
Name
())))
}
}
}
}
...
...
pkg/apiserver/apiserver_test.go
View file @
ff2fcd43
...
@@ -247,11 +247,18 @@ func (*SimpleRoot) IsAnAPIObject() {}
...
@@ -247,11 +247,18 @@ func (*SimpleRoot) IsAnAPIObject() {}
type
SimpleGetOptions
struct
{
type
SimpleGetOptions
struct
{
api
.
TypeMeta
`json:",inline"`
api
.
TypeMeta
`json:",inline"`
Param1
string
`json:"param1"
description:"description for param1"
`
Param1
string
`json:"param1"`
Param2
string
`json:"param2"
description:"description for param2"
`
Param2
string
`json:"param2"`
Path
string
`json:"atAPath"`
Path
string
`json:"atAPath"`
}
}
func
(
SimpleGetOptions
)
SwaggerDoc
()
map
[
string
]
string
{
return
map
[
string
]
string
{
"param1"
:
"description for param1"
,
"param2"
:
"description for param2"
,
}
}
func
(
*
SimpleGetOptions
)
IsAnAPIObject
()
{}
func
(
*
SimpleGetOptions
)
IsAnAPIObject
()
{}
type
SimpleList
struct
{
type
SimpleList
struct
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment