Compare commits
1 Commits
593c65c7b7
...
07ec6a612b
Author | SHA1 | Date | |
---|---|---|---|
|
07ec6a612b |
@@ -34,7 +34,3 @@ func TestSwaggerSet_1(t *testing.T) {
|
||||
fmt.Printf("type: %s, reqParam: %s, reqBody: %s, rsp: %s \n", msg.Type, reqParam, reqBody, rsp)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSwaggerSet_2(t *testing.T) {
|
||||
Run4()
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package swaggerset
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
@@ -28,28 +27,6 @@ type message struct {
|
||||
Response interface{}
|
||||
}
|
||||
|
||||
func Run4() {
|
||||
// Загружаем Swagger-документ
|
||||
loader := openapi3.NewLoader()
|
||||
doc, err := loader.LoadFromFile("swagger2.yaml")
|
||||
if err != nil {
|
||||
log.Fatalf("Ошибка загрузки Swagger-документа: %v", err)
|
||||
}
|
||||
|
||||
// Пример обработки путей
|
||||
for path, pathItem := range doc.Paths.Map() {
|
||||
fmt.Printf("Path: %s\n", path)
|
||||
|
||||
// Пример обработки методов
|
||||
if pathItem.Get != nil {
|
||||
handleOperation("GET", pathItem.Get)
|
||||
}
|
||||
if pathItem.Post != nil {
|
||||
handleOperation("POST", pathItem.Post)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Обработка операции (GET или POST)
|
||||
func handleOperation(method string, operation *openapi3.Operation) (reqParam, reqBody, rsp interface{}) {
|
||||
fmt.Printf(" Method: %s\n", method)
|
||||
|
Reference in New Issue
Block a user