From f4f20c3bf214e6d02012c9e6dcb826e8f24b7eef Mon Sep 17 00:00:00 2001 From: "Cui.Jiaqing" <291527070@qq.com> Date: Wed, 17 Jan 2024 17:32:39 +0800 Subject: [PATCH] openapi --- pkg/swagger/swagger_components.go | 1 + pkg/swagger/swagger_info.go | 22 +++++++++++++++ pkg/swagger/swagger_path.go | 47 +++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 pkg/swagger/swagger_components.go create mode 100644 pkg/swagger/swagger_info.go create mode 100644 pkg/swagger/swagger_path.go diff --git a/pkg/swagger/swagger_components.go b/pkg/swagger/swagger_components.go new file mode 100644 index 0000000..c0a891a --- /dev/null +++ b/pkg/swagger/swagger_components.go @@ -0,0 +1 @@ +package swagger diff --git a/pkg/swagger/swagger_info.go b/pkg/swagger/swagger_info.go new file mode 100644 index 0000000..af84674 --- /dev/null +++ b/pkg/swagger/swagger_info.go @@ -0,0 +1,22 @@ +package swagger + +// Info swagger info 根节点/** +type Info struct { + Title string `json:"title"` + Description string `json:"description"` + TermsOfService string `json:"termsOfService"` + Contact Contact `json:"contact"` + License License `json:"license"` + Version string `json:"version"` +} + +type Contact struct { + Name string `json:"name"` + Url string `json:"url"` + Email string `json:"email"` +} + +type License struct { + Name string `json:"name"` + Url string `json:"url"` +} diff --git a/pkg/swagger/swagger_path.go b/pkg/swagger/swagger_path.go new file mode 100644 index 0000000..0327942 --- /dev/null +++ b/pkg/swagger/swagger_path.go @@ -0,0 +1,47 @@ +package swagger + +type Path struct { + Tags []string `json:"tags"` + Summary string `json:"summary"` + OperationId string `json:"operationId"` + Parameters []Parameters `json:"parameters"` + RequestBody RequestBody `json:"requestBody"` + Responses map[string]ResponsesItem `json:"responses"` + Security []Security `json:"security"` +} + +type Parameters struct { + Name string `json:"name"` + In string `json:"in"` + Description string `json:"description"` + Required bool `json:"required"` + Schema struct { + Type string `json:"type"` + } `json:"schema"` +} +type RequestBody struct { + Content map[string]ContentType `json:"content"` +} + +type ContentType struct { + Schema Schema `json:"schema"` +} + +type Schema struct { + Type string `json:"type"` + Properties map[string]Property `json:"properties"` + Required []string `json:"required"` +} +type Property struct { + Description string `json:"description"` + Type string `json:"type"` +} + +type ResponsesItem struct { + Description string `json:"description"` + Content map[string]interface{} `json:"content"` +} + +type Security struct { + PetstoreAuth []string `json:"petstore_auth"` +}