Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: thrift-gen-rpc-swagger plugin #4

Merged
merged 16 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ jobs:
run: chmod +x ./hack/tools.sh

- name: Unit Test
if: success() && files.exists('**/*_test.go')
run: make test
109 changes: 109 additions & 0 deletions common/consts/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright 2024 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package consts

const (
HttpMethodGet = "GET"
HttpMethodPost = "POST"
HttpMethodPut = "PUT"
HttpMethodPatch = "PATCH"
HttpMethodDelete = "DELETE"
HttpMethodOptions = "OPTIONS"
HttpMethodHead = "HEAD"
)

const (
ApiGet = "api.get"
ApiPost = "api.post"
ApiPut = "api.put"
ApiPatch = "api.patch"
ApiDelete = "api.delete"
ApiOptions = "api.options"
ApiHEAD = "api.head"
ApiAny = "api.any"
ApiQuery = "api.query"
ApiForm = "api.form"
ApiPath = "api.path"
ApiHeader = "api.header"
ApiCookie = "api.cookie"
ApiBody = "api.body"
ApiRawBody = "api.raw_body"
ApiBaseDomain = "api.base_domain"
ApiBaseURL = "api.baseurl"
OpenapiOperation = "openapi.operation"
OpenapiProperty = "openapi.property"
OpenapiSchema = "openapi.schema"
OpenapiParameter = "openapi.parameter"
OpenapiDocument = "openapi.document"
)

const (
CodeGenerationCommentPbHttp = "// Code generated by protoc-gen-http-swagger."
CodeGenerationCommentThriftHttp = "// Code generated by thrift-gen-http-swagger."
CodeGenerationCommentThriftRpc = "// Code generated by thrift-gen-rpc-swagger."
)

const (
PluginNameProtocHttpSwagger = "protoc-gen-http-swagger"
PluginNameThriftHttpSwagger = "thrift-gen-http-swagger"
PluginNameThriftRpcSwagger = "thrift-gen-rpc-swagger"
)

const (
OpenAPIVersion = "3.0.3"
InfoURL = "https://github.com/hertz-contrib/swagger-generate/"
URLDefaultPrefixHTTP = "http://"
URLDefaultPrefixHTTPS = "https://"
DefaultInfoTitle = "API generated by "
DefaultInfoDesc = "API description"
DefaultInfoVersion = "0.0.1"

DocumentOptionServiceType = "service"
DocumentOptionStructType = "struct"

DefaultResponseDesc = "Successful response"
DefaultExceptionDesc = "Exception response"
StatusOK = "200"
StatusBadRequest = "400"
SchemaObjectType = "object"
ComponentSchemaPrefix = "#/components/schemas/"
ComponentSchemaSuffixBody = "Body"
ComponentSchemaSuffixRawBody = "RawBody"

ContentTypeJSON = "application/json"
ContentTypeFormMultipart = "multipart/form-data"
ContentTypeFormURLEncoded = "application/x-www-form-urlencoded"
ContentTypeRawBody = "text/plain"

ParameterInQuery = "query"
ParameterInHeader = "header"
ParameterInPath = "path"
ParameterInCookie = "cookie"

DefaultOutputDir = "swagger"
DefaultOutputYamlFile = "openapi.yaml"
DefaultOutputSwaggerFile = "swagger.go"

DefaultServerURL = "http://127.0.0.1:8888"
DefaultKitexAddr = "127.0.0.1:8888"

ParameterNameTTHeader = "ttheader"
ParameterDescription = "metainfo for request"

CommentPatternRegexp = `//\s*(.*)|/\*([\s\S]*?)\*/`
LinterRulePatternRegexp = `\(-- .* --\)`
)
Loading
Loading