Bug Report Checklist
Description
Calling a delete method with just a path parameter fails with
# python3 bug.py
Exception when calling Api: (0)
Reason: Cannot prepare a request message for provided
arguments. Please check that your arguments match
declared content type.
This works with a client generated with the standard python generator, changing the method call to
#main_api_instance.delete_coffee(path_params={"id":"12"})
main_api_instance.delete_coffee(12)
openapi-generator version
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: delete
description: delete with empty body
version: 0.0.1
tags:
- name: main
servers:
- url: https://localhost:62602/api/v1
description: Production server
paths:
"/coffees/{id}":
delete:
operationId: deleteCoffee
summary: Delete coffee
description: Delete the coffee identified by the given id
tags:
- main
parameters:
- name: id
in: path
description: The internal object id
required: true
schema:
type: string
responses:
"200":
description: OK
default:
description: Unexpected error
Generation Details
Client generated with the current python_experimental from trunk
Steps to reproduce
# java -jar ./tools/Generator/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i delete-bug.yaml -g python-experimental -o ./_build/client/
# cd _build/client
# sudo python3 setup.py install
# cd
# python3 bug.py
with bug.py as follows
from pprint import pprint
import time
import openapi_client
from openapi_client.api import main_api
# Logging
import os
import logging
logging.basicConfig(level=os.environ.get("LOGLEVEL", "DEBUG"))
# Configure API
configuration = openapi_client.Configuration(
server_index = 0
)
configuration.verify_ssl = False
configuration.debug = True
# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
try:
main_api_instance = main_api.MainApi(api_client)
main_api_instance.delete_coffee(path_params={"id":"12"})
#main_api_instance.delete_coffee(12)
except openapi_client.ApiException as e:
print("Exception when calling Api: %s\n" % e)
Related issues/PRs
None found
Suggest a fix
This fails in rest.py:request() which is called with
method=DELETE
url=https://localhost:62602/api/v1/coffees/12
query_params=None
headers?{'User-Agent': 'OpenAPI-Generator/1.0.0/python'}
fields=None
body=None
as body is None. Maybe body should be the empty string here?
It works in the client generated with the standard python generator as this is covered by the first case as 'Content-Type' not in headers.
Maybe here the case of body=None and query_params=None with Content-Type not in headers should be covered here by setting the body=""?
Bug Report Checklist
Description
Calling a delete method with just a path parameter fails with
This works with a client generated with the standard python generator, changing the method call to
openapi-generator version
OpenAPI declaration file content or url
Generation Details
Client generated with the current python_experimental from trunk
Steps to reproduce
with
bug.pyas followsRelated issues/PRs
None found
Suggest a fix
This fails in
rest.py:request()which is called withas
bodyis None. Maybebodyshould be the empty string here?It works in the client generated with the standard python generator as this is covered by the first case as
'Content-Type' not in headers.Maybe here the case of
body=Noneandquery_params=NonewithContent-Typenot in headers should be covered here by setting thebody=""?