Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

[BUG] additionalProperties sometimes breaks #92

@spacether

Description

@spacether

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

When using an SchemaObject, that contains the additionalProperties attribute with type: object, I get the error:
AttributeError: type object 'MetaOapg' has no attribute 'additional_properties'.

As I have tested this, I have come to the conclusion that this only occurs, when there are other Schemas with additionalProperties defined.

openapi-generator version

Version 6.3.0 Python

OpenAPI declaration file content or url

This my minimal Example to reproduce the bug

openapi: 3.0.0
info:
  version: 1.0.0
  title: issue 13997 spec
  license:
    name: Apache-2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
servers: []
tags: []
paths: {}
components:
  schemas:
    Event:
      type: object
      required:
        - apiVersion
        - modules
      properties:
        apiVersion:
          type: string
        timeout:
          type: integer
          format: int32
          example: 10000
        modules:
          type: object
          additionalProperties:
            type: object
    UploadEvent:
      type: object
      properties:
        uploadId:
          type: string
          example: "6Ms5S3"
        result:
          type: object
          additionalProperties:
            type: array
            items:
              type: object

And for some reason this works (without the second event):

openapi: 3.0.0
info:
  version: 1.0.0
  title: issue 13997 spec
  license:
    name: Apache-2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
servers: []
tags: []
paths: {}
components:
  schemas:
    Event:
      type: object
      required:
        - apiVersion
        - modules
      properties:
        apiVersion:
          type: string
        timeout:
          type: integer
          format: int32
          example: 10000
        modules:
          type: object
          additionalProperties:
            type: object
Generation Details

java -jar openapi-generator-cli-6.3.0.jar generate -i additional.yaml -g python

Steps to reproduce

Generate with specified yaml file above and try to import Event like: from openapi_client.model.event import Event

Complete Stacktrace
Traceback (most recent call last):
  File "sample.py", line 2, in <module>
    from devaice_web_api_client.model.event import Event
  File "/home/user/.local/lib/python3.8/site-packages/openapi_client/model/event.py", line 26, in <module>
    class Event(
  File "/home/user/.local/lib/python3.8/site-packages/openapi_client/model/event.py", line 36, in Event
    class MetaOapg:
  File "/home/user/.local/lib/python3.8/site-packages/openapi_client/model/event.py", line 42, in MetaOapg
    class properties:
  File "/home/user/.local/lib/python3.8/site-packages/openapi_client/model/event.py", line 46, in properties
    class modules(
  File "/home/user/.local/lib/python3.8/site-packages/openapi_client/model/event.py", line 65, in modules
    **kwargs: typing.Union[MetaOapg.additional_properties, dict, frozendict.frozendict, ],
AttributeError: type object 'MetaOapg' has no attribute 'additional_properties'

Synonym issue from OpenAPITools/openapi-generator#14078
Thank you @Poolmann

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions