Open
Description
Bug Report Checklist
- [ x] Have you provided a full/minimal spec to reproduce the issue?
- [ x] Have you validated the input using an OpenAPI validator (example)?
- [ x] Have you tested with the latest master to confirm the issue still exists?
- [x ] Have you searched for related issues/PRs?
- [x ] What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The python generator produces stubs which fail with an AttributeError on a query parameter of type string restricted by an enum.
openapi-generator version
I tested this on the current v7.0.0-beta as well as with todays trunk using the python (was python-nextgen) generator. This worked with the python and python-experimental generators of v6.0.
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: ""
version: ""
paths:
/items:
get:
operationId: getHidden
summary: Get all hidden
description: Returns all hidden entries
parameters:
- $ref: "#/components/parameters/hidden"
responses:
200:
description: OK
components:
parameters:
hidden:
name: hidden
in: query
schema:
type: string
enum:
- only
- 'true'
Generation Details
# java -jar openapi-generator-7.0.0-beta/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i openapi-schema.yaml -g python
# java -jar openapi-generator-master-2023-07-11/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i openapi-schema.yaml -g python
Steps to reproduce
import time
import os
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
configuration = openapi_client.Configuration(
host = "http://localhost"
)
with openapi_client.ApiClient(configuration) as api_client:
api_instance = openapi_client.DefaultApi(api_client)
api_instance.get_hidden(hidden='only')
results in
...
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
File "./openapi_client/api/default_api.py", line 74, in get_hidden
return self.get_hidden_with_http_info(hidden, **kwargs) # noqa: E501
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
File "./openapi_client/api/default_api.py", line 149, in get_hidden_with_http_info
_query_params.append(('hidden', _params['hidden'].value))
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'value'
Related issues/PRs
Possible related to Issue #14524
Suggest a fix
Sorry