Skip to content

[BUG] python pydantic - generates invalid files #2474

Description

@black-snow

Describe the bug.

asyncapi generate models python backend/docs/asyncapi.yml --pyDantic -o backend/src/generated/models --packageName=src.generated.models

produces invalid files like:

class AnonymousSchema1(BaseModel): 
  id: str = Field()
  source: str = Field(default=''xxx'', frozen=True)

I also don't see why some files/classes are created with a reasonable name and others are AnonymousSchemaN. Adding a title or name doesn't seem to make the difference.

Expected behavior

The value of default param should be a proper string - so " or ''' enclosed.

Screenshots

How to Reproduce

The source for this should be:

channels:
  A:
    # ...
    messages:
      M:
        description: xyz
        contentType: application/json
        payload:
          allOf:
            - allOf: # ...
            - description: xyz
              type: object
              properties:
                type:
                  type: string
                  # this here
                  const: xxx
                source:
                  type: string
                  # this as well
                  const: xxx
                subject:
                  type: string
                  const: xyz
              required:
                - type
                - source
                - subject

🖥️ Device Information [optional]

  • Operating System (OS): macOS

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

No, someone else can work on it

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions