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

Unable to run generated code #60

Closed
mxklb opened this issue Jun 2, 2021 · 7 comments · Fixed by #85
Closed

Unable to run generated code #60

mxklb opened this issue Jun 2, 2021 · 7 comments · Fixed by #85
Assignees
Labels
bug Something isn't working released

Comments

@mxklb
Copy link

mxklb commented Jun 2, 2021

Describe the bug

Looks like a bug in 0.2.8 code generation.

When generating code by something like this:

components:
  messages:
    controlDmx:
      name: controlDmx
      title: Control DMX Lights
      summary: A message to control dmx light features.
      payload:
        $ref: "#/components/schemas/control"
  schemas:
    control:
      type: object
      title: DMX Control
      summary: Set dmx features for given groups.
      description: |
        Bla blub ..
      properties:
        time:
          $ref: "#/components/schemas/timestamp"
    timestamp:
      type: string
      title: time
      summary: Date and Time of the message
      description: |
        The timestamp of the message (optional)
      format: date-time

This produces a timestamp.py class which is invalid:

class Timestamp(Entity):

    def __init__(
            self):

This happens for all schema objects that do not define any properties = all classes without __init__ arguments.

Expected behavior

Generated classes with no properties defined shall be valid python code.

How to fix it

All these bad __init__ methods shall simple add a pass.

class Timestamp(Entity):

    def __init__(
            self):
            pass

After manually adding pass to all these wrongly syntaxed __init__ methods the generated code works!

@mxklb mxklb added the bug Something isn't working label Jun 2, 2021
@github-actions
Copy link

github-actions bot commented Aug 2, 2021

This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
Thank you for your contributions ❤️

@github-actions
Copy link

github-actions bot commented Oct 2, 2021

This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
Thank you for your contributions ❤️

@github-actions github-actions bot added the stale label Oct 2, 2021
@derberg derberg removed the stale label Oct 4, 2021
@derberg
Copy link
Member

derberg commented Oct 4, 2021

@damaru-inc any chance you could have a look?

@mxklb
Copy link
Author

mxklb commented Oct 4, 2021

I'll check the following days again ..

@mxklb
Copy link
Author

mxklb commented Oct 4, 2021

VERSION=0.2.10 still creates invalid python class code!

This happens for all schema objects that do not define any properties, or am I doing something wrong?

from enum import Enum
from typing import Sequence
from entity import Entity



class Timestamp(Entity):

    def __init__(
            self):

init method does not do anything, no code after : is still bad/invalid python code which is not exectuable.

Furthermore no main.py is generated (as it was in former version 0. 2.8) - but maybe this has changed .. tbd

@damaru-inc
Copy link
Contributor

I'll be able to fix this this week.

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 0.2.12 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
4 participants