OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Python] models.set missing, when using uniqeItems: true with python-flask
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I want to use uniqueItems: true in my spec, but the generated python-flask code won't run. It throws a ModuleNotFoundError when looking for openapi_server.models.set.Set.
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/openapi_server/__main__.py", line 5, in <module>
from openapi_server import encoder
File "/tmp/openapi_server/encoder.py", line 4, in <module>
from openapi_server.models.base_model_ import Model
File "/tmp/openapi_server/models/__init__.py", line 6, in <module>
from openapi_server.models.name import Name
File "/tmp/openapi_server/models/name.py", line 9, in <module>
from openapi_server.models.set import Set
ModuleNotFoundError: No module named 'openapi_server.models.set'
openapi-generator version
5.0.1 - based on what it says during startup
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: yooneek
contact:
email: different@yooneek.com
license:
name: MIT
version: 1.0.0
components:
schemas:
Name:
type: object
properties:
id:
type: string
parts:
type: array
uniqueItems: true
items:
type: string
securitySchemes:
basic:
type: http
scheme: basic
paths:
/name/{name_id}:
summary: Operations on a name
get:
summary: Get an name
operationId: get_name
parameters:
- name: name_id
in: path
description: ID of name to get
required: true
schema:
type: string
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Name'
Generation Details
Not sure what "generation details" means - unless it's how I generated the spec above? This was part of a much larger spec for which I'm trying to generate a POC service. This project has been a huge help, thanks!
Steps to reproduce
Save the above yaml to openapi.yaml and run
npx @openapitools/openapi-generator-cli generate -i openapi.yaml -g python-flask
Related issues/PRs
I couldn't find anything that seems closely related
Suggest a fix
Seems like the models.set module just isn't included? Hopefully it's a simple oversight...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the documented npx generation command with the provided OpenAPI YAML, then inspect the generated models/init.py and models/name.py imports alongside the missing openapi_server.models.set module. Confirm the generated python-flask project starts without ModuleNotFoundError when uniqueItems is used.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, openapi, python
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100