1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 12:54:53 -05:00

Add spectral linter for Swagger (#20321)

[spectral](https://github.com/stoplightio/spectral) lints
openapi/swagger files for mistakes of which it has identified a few and
which I've fixed.

I had to put it into `lint-frontend` because it depends on node_modules
so can not run on Drone during the backend target. I plan to refactor
these targets later to `lint-js` and `lint-go` so that they are
categorized based on the tool dependencies.
This commit is contained in:
silverwind 2022-07-12 01:07:16 +02:00 committed by GitHub
parent 8a7d1a3516
commit c8e0fd0bcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 2904 additions and 101 deletions

12
.spectral.yaml Normal file
View file

@ -0,0 +1,12 @@
extends: [[spectral:oas, all]]
rules:
info-contact: off
oas2-api-host: off
oas2-parameter-description: off
oas2-schema: off
oas2-valid-schema-example: off
openapi-tags: off
operation-description: off
operation-singular-tag: off
operation-tag-defined: off

View file

@ -312,6 +312,7 @@ lint: lint-frontend lint-backend
lint-frontend: node_modules lint-frontend: node_modules
npx eslint --color --max-warnings=0 web_src/js build templates *.config.js docs/assets/js npx eslint --color --max-warnings=0 web_src/js build templates *.config.js docs/assets/js
npx stylelint --color --max-warnings=0 web_src/less npx stylelint --color --max-warnings=0 web_src/less
npx spectral lint -q -F hint $(SWAGGER_SPEC)
.PHONY: lint-backend .PHONY: lint-backend
lint-backend: golangci-lint vet editorconfig-checker lint-backend: golangci-lint vet editorconfig-checker

2888
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -45,6 +45,7 @@
}, },
"devDependencies": { "devDependencies": {
"@happy-dom/jest-environment": "4.0.1", "@happy-dom/jest-environment": "4.0.1",
"@stoplight/spectral-cli": "6.4.1",
"eslint": "8.15.0", "eslint": "8.15.0",
"eslint-plugin-html": "6.2.0", "eslint-plugin-html": "6.2.0",
"eslint-plugin-import": "2.26.0", "eslint-plugin-import": "2.26.0",

View file

@ -100,7 +100,7 @@ func GetHook(ctx *context.APIContext) {
// CreateHook create a hook for an organization // CreateHook create a hook for an organization
func CreateHook(ctx *context.APIContext) { func CreateHook(ctx *context.APIContext) {
// swagger:operation POST /orgs/{org}/hooks/ organization orgCreateHook // swagger:operation POST /orgs/{org}/hooks organization orgCreateHook
// --- // ---
// summary: Create a hook // summary: Create a hook
// consumes: // consumes:

View file

@ -107,9 +107,6 @@ type swaggerParameterBodies struct {
// in:body // in:body
EditUserOption api.EditUserOption EditUserOption api.EditUserOption
// in:body
MigrateRepoForm forms.MigrateRepoForm
// in:body // in:body
EditAttachmentOptions api.EditAttachmentOptions EditAttachmentOptions api.EditAttachmentOptions

View file

@ -1131,9 +1131,7 @@
"$ref": "#/responses/HookList" "$ref": "#/responses/HookList"
} }
} }
}
}, },
"/orgs/{org}/hooks/": {
"post": { "post": {
"consumes": [ "consumes": [
"application/json" "application/json"
@ -16078,12 +16076,6 @@
}, },
"x-go-package": "code.gitea.io/gitea/modules/structs" "x-go-package": "code.gitea.io/gitea/modules/structs"
}, },
"GitServiceType": {
"description": "GitServiceType represents a git service",
"type": "integer",
"format": "int64",
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
"GitTreeResponse": { "GitTreeResponse": {
"description": "GitTreeResponse returns a git tree", "description": "GitTreeResponse returns a git tree",
"type": "object", "type": "object",
@ -16473,94 +16465,6 @@
"x-go-name": "MergePullRequestForm", "x-go-name": "MergePullRequestForm",
"x-go-package": "code.gitea.io/gitea/services/forms" "x-go-package": "code.gitea.io/gitea/services/forms"
}, },
"MigrateRepoForm": {
"description": "MigrateRepoForm form for migrating repository\nthis is used to interact with web ui",
"type": "object",
"required": [
"clone_addr",
"uid",
"repo_name"
],
"properties": {
"auth_password": {
"type": "string",
"x-go-name": "AuthPassword"
},
"auth_token": {
"type": "string",
"x-go-name": "AuthToken"
},
"auth_username": {
"type": "string",
"x-go-name": "AuthUsername"
},
"clone_addr": {
"type": "string",
"x-go-name": "CloneAddr"
},
"description": {
"type": "string",
"x-go-name": "Description"
},
"issues": {
"type": "boolean",
"x-go-name": "Issues"
},
"labels": {
"type": "boolean",
"x-go-name": "Labels"
},
"lfs": {
"type": "boolean",
"x-go-name": "LFS"
},
"lfs_endpoint": {
"type": "string",
"x-go-name": "LFSEndpoint"
},
"milestones": {
"type": "boolean",
"x-go-name": "Milestones"
},
"mirror": {
"type": "boolean",
"x-go-name": "Mirror"
},
"mirror_interval": {
"type": "string",
"x-go-name": "MirrorInterval"
},
"private": {
"type": "boolean",
"x-go-name": "Private"
},
"pull_requests": {
"type": "boolean",
"x-go-name": "PullRequests"
},
"releases": {
"type": "boolean",
"x-go-name": "Releases"
},
"repo_name": {
"type": "string",
"x-go-name": "RepoName"
},
"service": {
"$ref": "#/definitions/GitServiceType"
},
"uid": {
"type": "integer",
"format": "int64",
"x-go-name": "UID"
},
"wiki": {
"type": "boolean",
"x-go-name": "Wiki"
}
},
"x-go-package": "code.gitea.io/gitea/services/forms"
},
"MigrateRepoOptions": { "MigrateRepoOptions": {
"description": "MigrateRepoOptions options for migrating repository's\nthis is used to interact with api v1", "description": "MigrateRepoOptions options for migrating repository's\nthis is used to interact with api v1",
"type": "object", "type": "object",