github.com/avenga/couper@v1.12.2/internal/test/open_api.go (about)

     1  package test
     2  
     3  import (
     4  	"bytes"
     5  	"text/template"
     6  )
     7  
     8  func (h *Helper) NewOpenAPIConf(path string) []byte {
     9  	openapiYAMLTemplate := template.New("openapiYAML")
    10  	_, err := openapiYAMLTemplate.Parse(`openapi: 3.0.1
    11  info:
    12    title: Test API
    13    version: "1.0"
    14  paths:
    15    {{.path}}:
    16      get:
    17        responses:
    18          200:
    19            description: OK
    20  `)
    21  	h.Must(err)
    22  
    23  	openapiYAML := &bytes.Buffer{}
    24  	h.Must(openapiYAMLTemplate.Execute(openapiYAML, map[string]string{"path": path}))
    25  	return openapiYAML.Bytes()
    26  }