python-openapi / openapi-core

Openapi-core is a Python library that adds client-side and server-side support for the OpenAPI v3.0 and OpenAPI v3.1 specification.
BSD 3-Clause "New" or "Revised" License
297 stars 132 forks source link

"Any Type" not supported #36

Open diogobaeder opened 6 years ago

diogobaeder commented 6 years ago

"Any Type" is part of the specification ( https://swagger.io/docs/specification/data-models/data-types/#any ), however this library does not support it.

The problem seems that, when creating the Schema for a schema spec that has {} as its value (meaning "anything can be used as input here"), it is created with an object type - see here: https://github.com/p1c2u/openapi-core/blob/master/openapi_core/schemas.py#L179 - it tries to infer "object" by default.

After checking the schema types ( https://github.com/p1c2u/openapi-core/blob/master/openapi_core/enums.py#L27 ) I can see that "any" is not there.

Please let me know if you need help with implementing that.

Thanks, Diogo

p1c2u commented 6 years ago

@diogobaeder this is tricky one. I need to have #34 AnyOf supprt done first.

diogobaeder commented 6 years ago

No problem. I was actually trying to use "Any Type" as a hack in place of oneOf, but now that you implemented oneOf I won't need this so soon. Thanks!

mmerickel commented 4 years ago

I'm also trying to use the any type. It's sort of working but I receive an unmarshaller warning that seems like it should just be removed? I'm using the following schema and data.

TemplateField:
  type: object
  properties:
    name:
      type: string
    default:
      nullable: true
{
  "name": "foo",
  "default": None
}

https://github.com/p1c2u/openapi-core/blob/97ec8c796746f72ef3298fe92078b5f80e1f66f7/openapi_core/unmarshalling/schemas/unmarshallers.py#L266