Revision control

Copy as Markdown

/*
* Generator Additional Properties Test
*
* This specification is used to ensure that the generator additional properties
* behave as intended.
*
* API version: 1.0.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
import (
"net/http"
"io"
"github.com/gin-gonic/gin"
)
type TestAPI struct {
}
// Post /Veرsion/v2/addDownloadProgress/true/roundtrip
// Upload a file and get it back to test progress signal
func (api *TestAPI) Roundtrip(c *gin.Context) {
content, err := io.ReadAll(c.Request.Body)
if err != nil {
c.String(http.StatusBadRequest, "Failed to read data from the request")
return
}
chunkSize := 1024
contentLen := len(content)
c.Header("Content-Type", "application/octet-stream")
for i := 0; i < contentLen; i += chunkSize {
end := i + chunkSize
if end > contentLen { end = contentLen }
// The first Write call implicitly sends http.StatusOk.
// So there is no need to do it explicitly.
c.Writer.Write(content[i:end])
c.Writer.Flush()
}
}
// GET /Veرsion/v2/enumUnknownDefaultCase
// Test unknown default enum case generation
func (api *TestAPI) GetEnumValue(c *gin.Context) {
// return an enum value unknown to the client (not "status1" or "status2")
c.JSON(http.StatusOK, gin.H{
"status": "unknown_value_from_server",
})
}