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

[python-experimental] Minor doc update, code comments and exception handling #5945

Merged
merged 7 commits into from
Apr 24, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ COERCION_INDEX_BY_TYPE = {
date: 10,
str: 11,
file_type: 12, # 'file_type' is an alias for the built-in 'file' or 'io.IOBase' type.
object: 13, # Any type, the 'type' attribute is not specified in a schema in a OAS document.
object: 13, # The 'type' attribute is not specified in the OAS schema.
Copy link
Contributor

@spacether spacether Apr 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastien-rosset can we discuss this over Skype?
I am concerned with doing it this way because many python classes inherit from the object type. So if we did it this way, it would allow in a ton of other class instances that we shouldn't like set, tuple, and arbitrary other classes.
Swagger/Openapi only allows specific types (string, int, float, dict, list, bytes, datetime, date, file_type, none_type)
My preference would be to instead convert these any type classes in python into a composed schema where it oneOf allows any type. As an added benefit, this could maybe be used to verify that we can have oneOf models with simple or complex types, which I'm not sure we can do.
Things like:
oneOf:

  • string
  • Pet

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastien-rosset can we discuss this over Skype?
I am concerned with doing it this way because many python classes inherit from the object type. So if we did it this way, it would allow in a ton of other class instances that we shouldn't like set, tuple, and arbitrary other classes.
Swagger/Openapi only allows specific types (string, int, float, dict, list, bytes, datetime, date, file_type, none_type)
My preference would be to instead convert these any type classes in python into a composed schema where it oneOf allows any type. As an added benefit, this could maybe be used to verify that we can have oneOf models with simple or complex types, which I'm not sure we can do.
Things like:
oneOf:

  • string
  • Pet

What do you think?

Yes I think that makes sense. Currently, when the type is "any", the generated openapi_types() function has a dict of properties to set of allowed types, and the allowed type is "object". That currently causes a runtime exception. So instead of having "object" in the list, we would enumerate all possible types: str, bool, date, datetime, dict, float, int, list

}

# these are used to limit what type conversions we try to do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def __eq__(self, other):
date: 10,
str: 11,
file_type: 12, # 'file_type' is an alias for the built-in 'file' or 'io.IOBase' type.
object: 13, # Any type, the 'type' attribute is not specified in a schema in a OAS document.
object: 13, # The 'type' attribute is not specified in the OAS schema.
}

# these are used to limit what type conversions we try to do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def __eq__(self, other):
date: 10,
str: 11,
file_type: 12, # 'file_type' is an alias for the built-in 'file' or 'io.IOBase' type.
object: 13, # Any type, the 'type' attribute is not specified in a schema in a OAS document.
object: 13, # The 'type' attribute is not specified in the OAS schema.
}

# these are used to limit what type conversions we try to do
Expand Down