[BUG] [Python] Regression on UUID types
See original GitHub issueBug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What’s the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What’s the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
A regression on v4.0.0-beta2
or latest fails during code generation when a
openapi-generator version
v4.0.0-beta2
OpenAPI declaration file content or url
---
openapi: 3.0.2
info:
title: My API
version: 0.1.0
description: Some description
paths:
/files/:
post:
summary: Upload file.
operationId: upload_file
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file_content:
type: string
format: binary
responses:
'201':
$ref: '#/components/responses/FileDetails'
components:
schemas:
BaseMetadata:
type: object
required:
- id
- url
properties:
id:
description: File identifier.
type: string
format: uuid
example: d06861a5-a14c-449c-bc9a-8f547186286a
url:
description: File URL
type: string
format: url
example: gs://data-bucket/d06861a5-a14c-449c-bc9a-8f547186286a
responses:
FileDetails:
description: File details.
content:
application/json:
schema:
$ref: '#/components/schemas/BaseMetadata'
Command line used for generation
The following command fails:
$ docker run --rm -v $PWD/tmp:/local openapitools/openapi-generator-cli:v4.0.0-beta2 generate -i /local/bug.yaml -g python -o /tmp/
[main] INFO o.o.c.ignore.CodegenIgnoreProcessor - No .openapi-generator-ignore file found.
[main] INFO o.o.c.languages.PythonClientCodegen - Environment variable PYTHON_POST_PROCESS_FILE not defined so the Python code may not be properly formatted. To define it, try 'export PYTHON_POST_PROCESS_FILE="/usr/local/bin/yapf -i"' (Linux/Mac)
[main] INFO o.o.c.languages.PythonClientCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[main] WARN o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] WARN o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
Exception in thread "main" java.lang.RuntimeException: Could not process model 'BaseMetadata'.Please make sure that your schema is correct!
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:454)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:897)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:354)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:61)
Caused by: java.lang.ClassCastException: java.util.UUID cannot be cast to java.lang.String
at org.openapitools.codegen.languages.PythonClientCodegen.toDefaultValue(PythonClientCodegen.java:657)
at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:1878)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3449)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:3397)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1748)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1138)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:449)
However, the previous version succeeds:
docker run --rm -v $PWD/tmp:/local openapitools/openapi-generator-cli:v4.0.0-beta generate -i /local/bug.yaml -g python -o /tmp/
... no errors ...
Steps to reproduce
- Download minimum working example
- Run docker image to generate code with
v4.0.0-beta2
tag orlatest
as shown on the example above.
Related issues/PRs
Suggest a fix
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Fix uuid.uuid1() core logic of uuid.getnode() needs refresh
I'm talking about this: https://bugs.python.org/issue39991#msg364435 I don't want to blame anyone. My intent here is to get more eyes on the ...
Read more >Adding UUID type to Cerberus leads to BAD_TYPE error
I'm attempting to add custom data types to Cerberus. The UUID class works as expected (it's a standard library class) but I'm not...
Read more >Working of Python UUID with Examples - eduCBA
This Python UUID module provides different immutable Objects and different versions of functions such as uuid1(), uuid3(), uuid4(), uuid5() which are used for ......
Read more >Bug #1332270 “Support bash-completion for non-UUID IDs” : Bugs ...
We need to refactor the Python-client bash-completion code to not care what cache-type it's writing to. Currently it hard-codes in `uuid` and `human_id`...
Read more >1438085 – fact collection behavior of 'virt.uuid' has changed for 'virt ...
Red Hat Product Errata, RHBA-2017:2083, 0, normal, SHIPPED_LIVE, python-rhsm and subscription-manager bug fix and enhancement update, 2017-08-01 18:14:19 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
UPDATE: issue with the R generator has been fixed via #2231
The fix has been merged into master. Please pull the latest to give it a try.