mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-03-25 17:53:03 -04:00
This will help api packages like https://codeberg.org/Cyborus/forgejo-api to generate clients that expose the header information as well. Currently `forgejo-api` has to edit the swagger json to generate a client crate that knows about headers. - Create separate response types for different endpoint behaviors - CommitList: Base type with only X-Total-Count header - CommitListWithPagination: For GetPullRequestCommits (pagination headers + X-Total-Count) - CommitListWithLegacyPagination: For GetAllCommits (pagination headers + X-Total-Count + deprecated X-Total) - ChangedFileList: Base type with only X-Total-Count header - ChangedFileListWithPagination: For GetPullRequestFiles (pagination headers + X-Total-Count) This ensures swagger documentation accurately reflects which headers each endpoint returns. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9380 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Cyborus <cyborus@disroot.org> Co-authored-by: Myers Carpenter <myers@maski.org> Co-committed-by: Myers Carpenter <myers@maski.org>
54 lines
1.9 KiB
Go
54 lines
1.9 KiB
Go
// Copyright 2014 The Gogs Authors. All rights reserved.
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package structs
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// AccessToken represents an API access token.
|
|
// swagger:response AccessToken
|
|
type AccessToken struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Token string `json:"sha1"`
|
|
TokenLastEight string `json:"token_last_eight"`
|
|
Scopes []string `json:"scopes"`
|
|
}
|
|
|
|
// AccessTokenList represents a list of API access token.
|
|
type AccessTokenList []*AccessToken
|
|
|
|
// CreateAccessTokenOption options when create access token
|
|
// swagger:model CreateAccessTokenOption
|
|
type CreateAccessTokenOption struct {
|
|
// required: true
|
|
Name string `json:"name" binding:"Required"`
|
|
// example: ["all", "read:activitypub","read:issue", "write:misc", "read:notification", "read:organization", "read:package", "read:repository", "read:user"]
|
|
Scopes []string `json:"scopes"`
|
|
}
|
|
|
|
// CreateOAuth2ApplicationOptions holds options to create an oauth2 application
|
|
type CreateOAuth2ApplicationOptions struct {
|
|
Name string `json:"name" binding:"Required"`
|
|
ConfidentialClient bool `json:"confidential_client"`
|
|
RedirectURIs []string `json:"redirect_uris" binding:"Required"`
|
|
}
|
|
|
|
// OAuth2Application represents an OAuth2 application.
|
|
// swagger:response OAuth2Application
|
|
type OAuth2Application struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
ClientID string `json:"client_id"`
|
|
ClientSecret string `json:"client_secret"`
|
|
ConfidentialClient bool `json:"confidential_client"`
|
|
RedirectURIs []string `json:"redirect_uris"`
|
|
Created time.Time `json:"created"`
|
|
}
|
|
|
|
// OAuth2ApplicationList represents a list of OAuth2 applications.
|
|
// swagger:response OAuth2ApplicationList
|
|
type OAuth2ApplicationList []*OAuth2Application
|