mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-09 22:36:12 +00:00
[Go][Server] Use the correct parameter name (#8144)
* Use the correct parameter name * Minor changes Co-authored-by: Bernardo Pastorelli <13519917-randomswdev@users.noreply.github.com>
This commit is contained in:
@@ -85,7 +85,7 @@ func (c *PetApiController) Routes() Routes {
|
||||
func (c *PetApiController) AddPet(w http.ResponseWriter, r *http.Request) {
|
||||
pet := &Pet{}
|
||||
if err := json.NewDecoder(r.Body).Decode(&pet); err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -105,10 +105,10 @@ func (c *PetApiController) DeletePet(w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
petId, err := parseInt64Parameter(params["petId"])
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
apiKey := r.Header.Get("apiKey")
|
||||
apiKey := r.Header.Get("api_key")
|
||||
result, err := c.service.DeletePet(r.Context(), petId, apiKey)
|
||||
//If an error occured, encode the error with the status code
|
||||
if err != nil {
|
||||
@@ -155,7 +155,7 @@ func (c *PetApiController) GetPetById(w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
petId, err := parseInt64Parameter(params["petId"])
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
result, err := c.service.GetPetById(r.Context(), petId)
|
||||
@@ -173,7 +173,7 @@ func (c *PetApiController) GetPetById(w http.ResponseWriter, r *http.Request) {
|
||||
func (c *PetApiController) UpdatePet(w http.ResponseWriter, r *http.Request) {
|
||||
pet := &Pet{}
|
||||
if err := json.NewDecoder(r.Body).Decode(&pet); err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -192,14 +192,14 @@ func (c *PetApiController) UpdatePet(w http.ResponseWriter, r *http.Request) {
|
||||
func (c *PetApiController) UpdatePetWithForm(w http.ResponseWriter, r *http.Request) {
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
params := mux.Vars(r)
|
||||
petId, err := parseInt64Parameter(params["petId"])
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
name := r.FormValue("name")
|
||||
@@ -219,20 +219,20 @@ func (c *PetApiController) UpdatePetWithForm(w http.ResponseWriter, r *http.Requ
|
||||
func (c *PetApiController) UploadFile(w http.ResponseWriter, r *http.Request) {
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
params := mux.Vars(r)
|
||||
petId, err := parseInt64Parameter(params["petId"])
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
additionalMetadata := r.FormValue("additionalMetadata")
|
||||
file, err := ReadFormFileToTempFile(r, "file")
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ func (c *StoreApiController) GetOrderById(w http.ResponseWriter, r *http.Request
|
||||
params := mux.Vars(r)
|
||||
orderId, err := parseInt64Parameter(params["orderId"])
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
result, err := c.service.GetOrderById(r.Context(), orderId)
|
||||
@@ -108,7 +108,7 @@ func (c *StoreApiController) GetOrderById(w http.ResponseWriter, r *http.Request
|
||||
func (c *StoreApiController) PlaceOrder(w http.ResponseWriter, r *http.Request) {
|
||||
order := &Order{}
|
||||
if err := json.NewDecoder(r.Body).Decode(&order); err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ func (c *UserApiController) Routes() Routes {
|
||||
func (c *UserApiController) CreateUser(w http.ResponseWriter, r *http.Request) {
|
||||
user := &User{}
|
||||
if err := json.NewDecoder(r.Body).Decode(&user); err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ func (c *UserApiController) CreateUser(w http.ResponseWriter, r *http.Request) {
|
||||
func (c *UserApiController) CreateUsersWithArrayInput(w http.ResponseWriter, r *http.Request) {
|
||||
user := &[]User{}
|
||||
if err := json.NewDecoder(r.Body).Decode(&user); err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ func (c *UserApiController) CreateUsersWithArrayInput(w http.ResponseWriter, r *
|
||||
func (c *UserApiController) CreateUsersWithListInput(w http.ResponseWriter, r *http.Request) {
|
||||
user := &[]User{}
|
||||
if err := json.NewDecoder(r.Body).Decode(&user); err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ func (c *UserApiController) UpdateUser(w http.ResponseWriter, r *http.Request) {
|
||||
username := params["username"]
|
||||
user := &User{}
|
||||
if err := json.NewDecoder(r.Body).Decode(&user); err != nil {
|
||||
w.WriteHeader(500)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user