Add swagger descriptions and needed structs (#53)
* Add swagger descriptions and needed structs * Remove missed TODO comment
This commit is contained in:
parent
0c3a0b0b5e
commit
d2f87fd3f9
8 changed files with 113 additions and 13 deletions
|
@ -4,15 +4,47 @@
|
||||||
|
|
||||||
package gitea
|
package gitea
|
||||||
|
|
||||||
// MarkdownOption markdown options
|
// SearchResults results of search
|
||||||
type MarkdownOption struct {
|
// swagger:response SearchResults
|
||||||
Text string
|
type SearchResults struct {
|
||||||
Mode string
|
OK bool `json:"ok"`
|
||||||
Context string
|
Data []*Repository `json:"data"`
|
||||||
Wiki bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SearchError error of failing search
|
||||||
|
// swagger:response SearchError
|
||||||
|
type SearchError struct {
|
||||||
|
OK bool `json:"ok"`
|
||||||
|
Error string `json:"error"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarkdownOption markdown options
|
||||||
|
// swagger:parameters renderMarkdown
|
||||||
|
type MarkdownOption struct {
|
||||||
|
// Text markdown to render
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
|
Text string
|
||||||
|
// Mode to render
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
|
Mode string
|
||||||
|
// Context to render
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
|
Context string
|
||||||
|
// Is it a wiki page ?
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
|
Wiki bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarkdownRender is a rendered markdown document
|
||||||
|
// swagger:response MarkdownRender
|
||||||
|
type MarkdownRender string
|
||||||
|
|
||||||
// ServerVersion wraps the version of the server
|
// ServerVersion wraps the version of the server
|
||||||
|
// swagger:response ServerVersion
|
||||||
type ServerVersion struct {
|
type ServerVersion struct {
|
||||||
Version string
|
Version string
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ type Permission struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Repository represents a API repository.
|
// Repository represents a API repository.
|
||||||
|
// swagger:response Repository
|
||||||
type Repository struct {
|
type Repository struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Owner *User `json:"owner"`
|
Owner *User `json:"owner"`
|
||||||
|
@ -42,6 +43,10 @@ type Repository struct {
|
||||||
Permissions *Permission `json:"permissions,omitempty"`
|
Permissions *Permission `json:"permissions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepositoryList represents a list of API repository.
|
||||||
|
// swagger:response RepositoryList
|
||||||
|
type RepositoryList []*Repository
|
||||||
|
|
||||||
// ListMyRepos lists all repositories for the authenticated user that has access to.
|
// ListMyRepos lists all repositories for the authenticated user that has access to.
|
||||||
func (c *Client) ListMyRepos() ([]*Repository, error) {
|
func (c *Client) ListMyRepos() ([]*Repository, error) {
|
||||||
repos := make([]*Repository, 0, 10)
|
repos := make([]*Repository, 0, 10)
|
||||||
|
@ -61,14 +66,37 @@ func (c *Client) ListOrgRepos(org string) ([]*Repository, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateRepoOption options when creating repository
|
// CreateRepoOption options when creating repository
|
||||||
|
//swagger:parameters createOrgRepo
|
||||||
type CreateRepoOption struct {
|
type CreateRepoOption struct {
|
||||||
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
// Name of the repository to create
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
|
// unique: true
|
||||||
|
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
||||||
|
// Description of the repository to create
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
Description string `json:"description" binding:"MaxSize(255)"`
|
Description string `json:"description" binding:"MaxSize(255)"`
|
||||||
Private bool `json:"private"`
|
// Is the repository to create private ?
|
||||||
AutoInit bool `json:"auto_init"`
|
//
|
||||||
Gitignores string `json:"gitignores"`
|
// in: body
|
||||||
License string `json:"license"`
|
Private bool `json:"private"`
|
||||||
Readme string `json:"readme"`
|
// Init the repository to create ?
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
|
AutoInit bool `json:"auto_init"`
|
||||||
|
// Gitignores to use
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
|
Gitignores string `json:"gitignores"`
|
||||||
|
// License to use
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
|
License string `json:"license"`
|
||||||
|
// Readme of the repository to create
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
|
Readme string `json:"readme"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateRepo creates a repository for authenticated user.
|
// CreateRepo creates a repository for authenticated user.
|
||||||
|
|
|
@ -34,9 +34,20 @@ func (c *Client) GetDeployKey(user, repo string, keyID int64) (*DeployKey, error
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateKeyOption options when create deploy key
|
// CreateKeyOption options when create deploy key
|
||||||
|
// swagger:parameters userCurrentPostKey
|
||||||
type CreateKeyOption struct {
|
type CreateKeyOption struct {
|
||||||
|
// Title of the key to add
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
|
// required: true
|
||||||
|
// unique: true
|
||||||
Title string `json:"title" binding:"Required"`
|
Title string `json:"title" binding:"Required"`
|
||||||
Key string `json:"key" binding:"Required"`
|
// An armored SSH key to add
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
|
// required: true
|
||||||
|
// unique: true
|
||||||
|
Key string `json:"key" binding:"Required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateDeployKey options when create one deploy key
|
// CreateDeployKey options when create one deploy key
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// WatchInfo represents a API watch status of one repository
|
// WatchInfo represents a API watch status of one repository
|
||||||
|
// swagger:response WatchInfo
|
||||||
type WatchInfo struct {
|
type WatchInfo struct {
|
||||||
Subscribed bool `json:"subscribed"`
|
Subscribed bool `json:"subscribed"`
|
||||||
Ignored bool `json:"ignored"`
|
Ignored bool `json:"ignored"`
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// User represents a API user.
|
// User represents a API user.
|
||||||
|
// swagger:response User
|
||||||
type User struct {
|
type User struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
UserName string `json:"login"`
|
UserName string `json:"login"`
|
||||||
|
@ -18,6 +19,10 @@ type User struct {
|
||||||
AvatarURL string `json:"avatar_url"`
|
AvatarURL string `json:"avatar_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UserList represents a list of API user.
|
||||||
|
// swagger:response UserList
|
||||||
|
type UserList []*User
|
||||||
|
|
||||||
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
|
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
|
||||||
func (u User) MarshalJSON() ([]byte, error) {
|
func (u User) MarshalJSON() ([]byte, error) {
|
||||||
// Re-declaring User to avoid recursion
|
// Re-declaring User to avoid recursion
|
||||||
|
|
|
@ -18,11 +18,16 @@ func BasicAuthEncode(user, pass string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccessToken represents a API access token.
|
// AccessToken represents a API access token.
|
||||||
|
// swagger:response AccessToken
|
||||||
type AccessToken struct {
|
type AccessToken struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Sha1 string `json:"sha1"`
|
Sha1 string `json:"sha1"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AccessTokenList represents a list of API access token.
|
||||||
|
// swagger:response AccessTokenList
|
||||||
|
type AccessTokenList []*AccessToken
|
||||||
|
|
||||||
// ListAccessTokens lista all the access tokens of user
|
// ListAccessTokens lista all the access tokens of user
|
||||||
func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error) {
|
func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error) {
|
||||||
tokens := make([]*AccessToken, 0, 10)
|
tokens := make([]*AccessToken, 0, 10)
|
||||||
|
@ -31,6 +36,7 @@ func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateAccessTokenOption options when create access token
|
// CreateAccessTokenOption options when create access token
|
||||||
|
// swagger:parameters userCreateToken
|
||||||
type CreateAccessTokenOption struct {
|
type CreateAccessTokenOption struct {
|
||||||
Name string `json:"name" binding:"Required"`
|
Name string `json:"name" binding:"Required"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,12 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GPGKeyList represents a list of GPGKey
|
||||||
|
// swagger:response GPGKeyList
|
||||||
|
type GPGKeyList []*GPGKey
|
||||||
|
|
||||||
// GPGKey a user GPG key to sign commit and tag in repository
|
// GPGKey a user GPG key to sign commit and tag in repository
|
||||||
|
// swagger:response GPGKey
|
||||||
type GPGKey struct {
|
type GPGKey struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
PrimaryKeyID string `json:"primary_key_id"`
|
PrimaryKeyID string `json:"primary_key_id"`
|
||||||
|
@ -28,13 +33,20 @@ type GPGKey struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GPGKeyEmail a email attache to a GPGKey
|
// GPGKeyEmail a email attache to a GPGKey
|
||||||
|
// swagger:model GPGKeyEmail
|
||||||
type GPGKeyEmail struct {
|
type GPGKeyEmail struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Verified bool `json:"verified"`
|
Verified bool `json:"verified"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateGPGKeyOption options create user GPG key
|
// CreateGPGKeyOption options create user GPG key
|
||||||
|
// swagger:parameters userCurrentPostGPGKey
|
||||||
type CreateGPGKeyOption struct {
|
type CreateGPGKeyOption struct {
|
||||||
|
// An armored GPG key to add
|
||||||
|
//
|
||||||
|
// in: body
|
||||||
|
// required: true
|
||||||
|
// unique: true
|
||||||
ArmoredKey string `json:"armored_public_key" binding:"Required"`
|
ArmoredKey string `json:"armored_public_key" binding:"Required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,12 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// PublicKeyList represents a list of PublicKey
|
||||||
|
// swagger:response PublicKeyList
|
||||||
|
type PublicKeyList []*PublicKey
|
||||||
|
|
||||||
// PublicKey publickey is a user key to push code to repository
|
// PublicKey publickey is a user key to push code to repository
|
||||||
|
// swagger:response PublicKey
|
||||||
type PublicKey struct {
|
type PublicKey struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
|
|
Loading…
Reference in a new issue