[SWAGGER] update swagger with latest webhook changes and re-render web services (#184)

This commit is contained in:
Johannes Batzill 2023-01-11 17:41:01 -08:00 committed by GitHub
parent a74d779dc4
commit d4d74f0f44
4 changed files with 421 additions and 26 deletions

View File

@ -38,8 +38,10 @@ func (webhookParent) Enum() []interface{} {
// webhookType is used to overshadow fields Parent & Triggers of types.Webhook.
type webhookType struct {
types.Webhook
ParentType webhookParent `json:"parent_type"`
Triggers []webhookTrigger `json:"triggers"`
ParentType webhookParent `json:"parent_type"`
Triggers []webhookTrigger `json:"triggers"`
LatestExecutionResult *webhookExecutionResult `json:"latest_execution_result,omitempty"`
HasSecret bool `json:"has_secret"`
}
type createWebhookRequest struct {

View File

@ -15,14 +15,14 @@ export const PullRequestMetaLine: React.FC<TypesPullReq & Pick<GitInfoProps, 're
target_branch,
source_branch,
author,
updated,
edited,
merged,
state
}) => {
const { getString } = useStrings()
const { routes } = useAppContext()
const vars = {
user: <strong>{author?.name}</strong>,
user: <strong>{author?.display_name}</strong>,
number: <strong>5</strong>, // TODO: No data from backend now
target: (
<GitRefLink
@ -47,7 +47,7 @@ export const PullRequestMetaLine: React.FC<TypesPullReq & Pick<GitInfoProps, 're
</Text>
<PipeSeparator height={9} />
<Text inline className={cx(css.metaline, css.time)}>
<ReactTimeago date={updated as number} />
<ReactTimeago date={edited as number} />
</Text>
</Layout.Horizontal>
</Container>

View File

@ -7,6 +7,8 @@ import { getConfig } from '../config'
export const SPEC_VERSION = '1.0.0'
export type EnumAccessGrant = number
export type EnumMergeMethod = string
export type EnumParentResourceType = string
export type EnumPathTargetType = string
@ -19,7 +21,7 @@ export type EnumPullReqState = string
export type EnumTokenType = string
export type EnumWebhookExecutionResult = string
export type EnumWebhookExecutionResult = string | null
export type EnumWebhookParent = string
@ -114,6 +116,8 @@ export interface OpenapiCreateSpaceRequest {
}
export interface OpenapiCreateWebhookRequest {
description?: string
display_name?: string
enabled?: boolean
insecure?: boolean
secret?: string
@ -134,6 +138,12 @@ export interface OpenapiGetContentOutput {
type?: OpenapiContentType
}
export interface OpenapiMergePullReq {
delete_branch?: boolean
force?: boolean
method?: EnumMergeMethod
}
export interface OpenapiMoveRepoRequest {
keep_as_alias?: boolean
parent_id?: number | null
@ -146,6 +156,15 @@ export interface OpenapiMoveSpaceRequest {
uid?: string | null
}
export interface OpenapiReviewSubmitPullReqRequest {
decision?: string
message?: string
}
export interface OpenapiReviewerAddPullReqRequest {
reviewer_id?: number
}
export interface OpenapiUpdatePullReqRequest {
description?: string
title?: string
@ -162,6 +181,8 @@ export interface OpenapiUpdateSpaceRequest {
}
export interface OpenapiUpdateWebhookRequest {
description?: string | null
display_name?: string | null
enabled?: boolean | null
insecure?: boolean | null
secret?: string | null
@ -169,7 +190,7 @@ export interface OpenapiUpdateWebhookRequest {
url?: string | null
}
export type OpenapiWebhookExecutionResult = 'success' | 'retriable_error' | 'fatal_error'
export type OpenapiWebhookExecutionResult = 'success' | 'retriable_error' | 'fatal_error' | null
export interface OpenapiWebhookExecutionType {
created?: number
@ -192,9 +213,13 @@ export type OpenapiWebhookTrigger = 'branch_created' | 'branch_updated' | 'branc
export interface OpenapiWebhookType {
created?: number
created_by?: number
description?: string
display_name?: string
enabled?: boolean
has_secret?: boolean
id?: number
insecure?: boolean
latest_execution_result?: OpenapiWebhookExecutionResult
parent_id?: number
parent_type?: OpenapiWebhookParent
triggers?: OpenapiWebhookTrigger[] | null
@ -314,7 +339,7 @@ export interface TypesPullReq {
description?: string
edited?: number
id?: number
merge_strategy?: string | null
merge_strategy?: EnumMergeMethod
merged?: number | null
merger?: TypesPrincipalInfo
number?: number
@ -324,8 +349,6 @@ export interface TypesPullReq {
target_branch?: string
target_repo_id?: number
title?: string
updated?: number
version?: number
}
export interface TypesPullReqActivity {
@ -346,8 +369,6 @@ export interface TypesPullReqActivity {
sub_order?: number
text?: string
type?: EnumPullReqActivityType
updated?: number
version?: number
}
export interface TypesRepository {
@ -435,8 +456,8 @@ export interface TypesWebhookExecutionRequest {
export interface TypesWebhookExecutionResponse {
body?: string
headers?: string
status?: number
status_code?: string
status?: string
status_code?: number
}
export interface UserUpdateInput {
@ -1445,6 +1466,140 @@ export const useCommentUpdatePullReq = ({
{ base: getConfig('code'), pathParams: { repo_ref, pullreq_number, pullreq_comment_id }, ...props }
)
export interface MergePullReqOpPathParams {
repo_ref: string
pullreq_number: number
}
export type MergePullReqOpProps = Omit<
MutateProps<void, UsererrorError, void, OpenapiMergePullReq, MergePullReqOpPathParams>,
'path' | 'verb'
> &
MergePullReqOpPathParams
export const MergePullReqOp = ({ repo_ref, pullreq_number, ...props }: MergePullReqOpProps) => (
<Mutate<void, UsererrorError, void, OpenapiMergePullReq, MergePullReqOpPathParams>
verb="POST"
path={`/repos/${repo_ref}/pullreq/${pullreq_number}/merge`}
base={getConfig('code')}
{...props}
/>
)
export type UseMergePullReqOpProps = Omit<
UseMutateProps<void, UsererrorError, void, OpenapiMergePullReq, MergePullReqOpPathParams>,
'path' | 'verb'
> &
MergePullReqOpPathParams
export const useMergePullReqOp = ({ repo_ref, pullreq_number, ...props }: UseMergePullReqOpProps) =>
useMutate<void, UsererrorError, void, OpenapiMergePullReq, MergePullReqOpPathParams>(
'POST',
(paramsInPath: MergePullReqOpPathParams) =>
`/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/merge`,
{ base: getConfig('code'), pathParams: { repo_ref, pullreq_number }, ...props }
)
export interface ReviewSubmitPullReqPathParams {
repo_ref: string
pullreq_number: number
}
export type ReviewSubmitPullReqProps = Omit<
MutateProps<void, UsererrorError, void, OpenapiReviewSubmitPullReqRequest, ReviewSubmitPullReqPathParams>,
'path' | 'verb'
> &
ReviewSubmitPullReqPathParams
export const ReviewSubmitPullReq = ({ repo_ref, pullreq_number, ...props }: ReviewSubmitPullReqProps) => (
<Mutate<void, UsererrorError, void, OpenapiReviewSubmitPullReqRequest, ReviewSubmitPullReqPathParams>
verb="POST"
path={`/repos/${repo_ref}/pullreq/${pullreq_number}/review`}
base={getConfig('code')}
{...props}
/>
)
export type UseReviewSubmitPullReqProps = Omit<
UseMutateProps<void, UsererrorError, void, OpenapiReviewSubmitPullReqRequest, ReviewSubmitPullReqPathParams>,
'path' | 'verb'
> &
ReviewSubmitPullReqPathParams
export const useReviewSubmitPullReq = ({ repo_ref, pullreq_number, ...props }: UseReviewSubmitPullReqProps) =>
useMutate<void, UsererrorError, void, OpenapiReviewSubmitPullReqRequest, ReviewSubmitPullReqPathParams>(
'POST',
(paramsInPath: ReviewSubmitPullReqPathParams) =>
`/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/review`,
{ base: getConfig('code'), pathParams: { repo_ref, pullreq_number }, ...props }
)
export interface ReviewerListPullReqPathParams {
repo_ref: string
pullreq_number: number
}
export type ReviewerListPullReqProps = Omit<
GetProps<void, UsererrorError, void, ReviewerListPullReqPathParams>,
'path'
> &
ReviewerListPullReqPathParams
export const ReviewerListPullReq = ({ repo_ref, pullreq_number, ...props }: ReviewerListPullReqProps) => (
<Get<void, UsererrorError, void, ReviewerListPullReqPathParams>
path={`/repos/${repo_ref}/pullreq/${pullreq_number}/reviewers`}
base={getConfig('code')}
{...props}
/>
)
export type UseReviewerListPullReqProps = Omit<
UseGetProps<void, UsererrorError, void, ReviewerListPullReqPathParams>,
'path'
> &
ReviewerListPullReqPathParams
export const useReviewerListPullReq = ({ repo_ref, pullreq_number, ...props }: UseReviewerListPullReqProps) =>
useGet<void, UsererrorError, void, ReviewerListPullReqPathParams>(
(paramsInPath: ReviewerListPullReqPathParams) =>
`/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/reviewers`,
{ base: getConfig('code'), pathParams: { repo_ref, pullreq_number }, ...props }
)
export interface ReviewerAddPullReqPathParams {
repo_ref: string
pullreq_number: number
}
export type ReviewerAddPullReqProps = Omit<
MutateProps<void, UsererrorError, void, OpenapiReviewerAddPullReqRequest, ReviewerAddPullReqPathParams>,
'path' | 'verb'
> &
ReviewerAddPullReqPathParams
export const ReviewerAddPullReq = ({ repo_ref, pullreq_number, ...props }: ReviewerAddPullReqProps) => (
<Mutate<void, UsererrorError, void, OpenapiReviewerAddPullReqRequest, ReviewerAddPullReqPathParams>
verb="PUT"
path={`/repos/${repo_ref}/pullreq/${pullreq_number}/reviewers`}
base={getConfig('code')}
{...props}
/>
)
export type UseReviewerAddPullReqProps = Omit<
UseMutateProps<void, UsererrorError, void, OpenapiReviewerAddPullReqRequest, ReviewerAddPullReqPathParams>,
'path' | 'verb'
> &
ReviewerAddPullReqPathParams
export const useReviewerAddPullReq = ({ repo_ref, pullreq_number, ...props }: UseReviewerAddPullReqProps) =>
useMutate<void, UsererrorError, void, OpenapiReviewerAddPullReqRequest, ReviewerAddPullReqPathParams>(
'PUT',
(paramsInPath: ReviewerAddPullReqPathParams) =>
`/repos/${paramsInPath.repo_ref}/pullreq/${paramsInPath.pullreq_number}/reviewers`,
{ base: getConfig('code'), pathParams: { repo_ref, pullreq_number }, ...props }
)
export interface ListRepositoryServiceAccountsPathParams {
repo_ref: string
}

View File

@ -1440,6 +1440,210 @@ paths:
description: Internal Server Error
tags:
- pullreq
/repos/{repo_ref}/pullreq/{pullreq_number}/merge:
post:
operationId: mergePullReqOp
parameters:
- in: path
name: repo_ref
required: true
schema:
type: string
- in: path
name: pullreq_number
required: true
schema:
type: integer
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/OpenapiMergePullReq'
responses:
'200':
description: OK
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Bad Request
'401':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Unauthorized
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Forbidden
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Not Found
'405':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Method Not Allowed
'409':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Conflict
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Unprocessable Entity
tags:
- pullreq
/repos/{repo_ref}/pullreq/{pullreq_number}/review:
post:
operationId: reviewSubmitPullReq
parameters:
- in: path
name: repo_ref
required: true
schema:
type: string
- in: path
name: pullreq_number
required: true
schema:
type: integer
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/OpenapiReviewSubmitPullReqRequest'
responses:
'204':
description: No Content
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Bad Request
'401':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Unauthorized
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Forbidden
'500':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Internal Server Error
tags:
- pullreq
/repos/{repo_ref}/pullreq/{pullreq_number}/reviewers:
get:
operationId: reviewerListPullReq
parameters:
- in: path
name: repo_ref
required: true
schema:
type: string
- in: path
name: pullreq_number
required: true
schema:
type: integer
responses:
'204':
description: No Content
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Bad Request
'401':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Unauthorized
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Forbidden
'500':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Internal Server Error
tags:
- pullreq
put:
operationId: reviewerAddPullReq
parameters:
- in: path
name: repo_ref
required: true
schema:
type: string
- in: path
name: pullreq_number
required: true
schema:
type: integer
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/OpenapiReviewerAddPullReqRequest'
responses:
'204':
description: No Content
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Bad Request
'401':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Unauthorized
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Forbidden
'500':
content:
application/json:
schema:
$ref: '#/components/schemas/UsererrorError'
description: Internal Server Error
tags:
- pullreq
/repos/{repo_ref}/service-accounts:
get:
operationId: listRepositoryServiceAccounts
@ -2844,6 +3048,8 @@ components:
schemas:
EnumAccessGrant:
type: integer
EnumMergeMethod:
type: string
EnumParentResourceType:
type: string
EnumPathTargetType:
@ -2857,6 +3063,7 @@ components:
EnumTokenType:
type: string
EnumWebhookExecutionResult:
nullable: true
type: string
EnumWebhookParent:
type: string
@ -3021,6 +3228,10 @@ components:
type: object
OpenapiCreateWebhookRequest:
properties:
description:
type: string
display_name:
type: string
enabled:
type: boolean
insecure:
@ -3058,6 +3269,15 @@ components:
type:
$ref: '#/components/schemas/OpenapiContentType'
type: object
OpenapiMergePullReq:
properties:
delete_branch:
type: boolean
force:
type: boolean
method:
$ref: '#/components/schemas/EnumMergeMethod'
type: object
OpenapiMoveRepoRequest:
properties:
keep_as_alias:
@ -3080,6 +3300,18 @@ components:
nullable: true
type: string
type: object
OpenapiReviewSubmitPullReqRequest:
properties:
decision:
type: string
message:
type: string
type: object
OpenapiReviewerAddPullReqRequest:
properties:
reviewer_id:
type: integer
type: object
OpenapiUpdatePullReqRequest:
properties:
description:
@ -3107,6 +3339,12 @@ components:
type: object
OpenapiUpdateWebhookRequest:
properties:
description:
nullable: true
type: string
display_name:
nullable: true
type: string
enabled:
nullable: true
type: boolean
@ -3130,6 +3368,7 @@ components:
- success
- retriable_error
- fatal_error
nullable: true
type: string
OpenapiWebhookExecutionType:
properties:
@ -3174,12 +3413,20 @@ components:
type: integer
created_by:
type: integer
description:
type: string
display_name:
type: string
enabled:
type: boolean
has_secret:
type: boolean
id:
type: integer
insecure:
type: boolean
latest_execution_result:
$ref: '#/components/schemas/OpenapiWebhookExecutionResult'
parent_id:
type: integer
parent_type:
@ -3367,8 +3614,7 @@ components:
id:
type: integer
merge_strategy:
nullable: true
type: string
$ref: '#/components/schemas/EnumMergeMethod'
merged:
nullable: true
type: integer
@ -3388,10 +3634,6 @@ components:
type: integer
title:
type: string
updated:
type: integer
version:
type: integer
type: object
TypesPullReqActivity:
properties:
@ -3436,10 +3678,6 @@ components:
type: string
type:
$ref: '#/components/schemas/EnumPullReqActivityType'
updated:
type: integer
version:
type: integer
type: object
TypesRepository:
properties:
@ -3592,9 +3830,9 @@ components:
headers:
type: string
status:
type: integer
status_code:
type: string
status_code:
type: integer
type: object
UserUpdateInput:
properties: