Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Python] models.set missing, when using uniqeItems: true with python-flask #8784

Open
5 tasks done
mariodsantana opened this issue Feb 21, 2021 · 4 comments
Open
5 tasks done

Comments

@mariodsantana
Copy link

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: [email protected]
  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...

@auto-labeler
Copy link

auto-labeler bot commented Feb 21, 2021

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@wing328
Copy link
Member

wing328 commented Feb 23, 2021

Can you please use the same spec and test with the python client generator as well? If it works (output looks to you), then we can plot the fix from the python client generator to python-flask server generator.

@mariodsantana
Copy link
Author

Good idea, I should have thought of that for the op. It doesn't error out, but it doesn't seem to apply the constraint. Using the python generator on the yaml above:

IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import openapi_client.models

In [2]: n = openapi_client.models.Name(id='id#1', parts=['same', 'same'])

In [3]: n
Out[3]: {'id': 'id#1', 'parts': ['same', 'same']}

In [4]: type(n)
Out[4]: openapi_client.model.name.Name

In [5]: n.openapi_types
Out[5]: {'id': (str,), 'parts': ([str],)}

In [6]: n.validations
Out[6]: {('parts',): {}}

@Kevin-Bannier
Copy link
Contributor

I can't reproduce this bug with 6.0.1. It's seems to be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants