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
Calling a method with a credential object holding a password attribute of type string with format: password
fails in the generated Python client code.
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.
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: ""
version: ""
paths:
/accounts/users/authenticate:
post:
operationId: authenticate
summary: Authenticate user
description: Authenticates user and returns bearer token
tags:
- account
security: []
requestBody:
description: User credentials
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Credentials"
responses:
200:
description: OK
components:
schemas:
Credentials:
type: object
properties:
email:
type: string
description: email address
example: me@work.com
password:
type: string
format: password
description: password
example: secret
required:
- email
- password
Generation Details
java -jar 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.AccountApi(api_client)
credentials = openapi_client.Credentials(email="me@email.com", password="123")
api_response = api_instance.authenticate(credentials)
fails with
Traceback (most recent call last):
File "<stdin>", line 5, 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/account_api.py", line 73, in authenticate
return self.authenticate_with_http_info(credentials, **kwargs) # noqa: E501
[ cut ]
File "./openapi_client/api_client.py", line 291, in sanitize_for_serialization
obj_dict = obj.to_dict()
^^^^^^^^^^^
AttributeError: 'SecretStr' object has no attribute 'to_dict'