Skip to content

Support for additionalProperties and "free form" objects #218

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

Closed
packyg opened this issue Oct 15, 2020 · 0 comments · Fixed by #252
Closed

Support for additionalProperties and "free form" objects #218

packyg opened this issue Oct 15, 2020 · 0 comments · Fixed by #252
Labels
✨ enhancement New feature or improvement

Comments

@packyg
Copy link
Contributor

packyg commented Oct 15, 2020

Is your feature request related to a problem? Please describe.

Our API contains some subresources that are not easily modeled in an OpenAPI spec. To get around this, we want to punt by modeling them as "free form" objects (an object with additionalProperties: true) and interacting with them as plain dicts instead of model classes.

Describe the solution you'd like

Support for the additionalProperties key, ideally in both use cases - specifying additional properties and specifying a freeform object

Additional properties:
MyModel:
  type: object
  properties:
    name:
      type: string
  additionalProperties:
    type: string

Should generate a model like

@attr.s(auto_attribs=True)
class MyModel:
  name: str
  additional_properties: Dict[str, str]
# ...
Free Form Object:
MyModel:
  type: object
  additionalProperties: true
@attr.s(auto_attribs=True)
class MyModel:
  additional_properties: Dict[str, Any]
# ...

Describe alternatives you've considered

Just using objects directly to declare these subresources instead of $refing a shared component schema to make it so the property gets generated as a plain dict.

Additional context

We do have a consistent model for the resource in question, just one that isn't easily modeled in OpenAPI. It's used as a property in several of our models so we would like to be able to indicate the relation by using a shared component schema.

@packyg packyg added the ✨ enhancement New feature or improvement label Oct 15, 2020
@dbanty dbanty linked a pull request Nov 28, 2020 that will close this issue
dbanty added a commit that referenced this issue Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant