Repository: vitalik/django-ninja

Issue:
[BUG] Package generates invalid openapi.json files
**Describe the bug**
The `openapi.json` file states that it is compliant with version 3.0.2, but it uses features that are only valid in 3.1.0.

Pydantic docs [say](https://docs.pydantic.dev/latest/why/): "Pydantic generates [JSON Schema version 2020-12](https://json-schema.org/draft/2020-12/release-notes.html), the latest version of the standard which is compatible with [OpenAPI 3.1](https://www.openapis.org/blog/2021/02/18/openapi-specification-3-1-released)." OpenAPI 3.0.2 supports an older JSON spec,  [JSON Schema Specification Wright Draft 00](https://tools.ietf.org/html/draft-wright-json-schema-00#section-4.2).

I think the solution to this could be to just increase the OpenAPI version in the generated file to 3.1.0.

Here is an example of the errors this issue causes. This schema:
```python
class Book(Schema):
    """Used for filtering."""

    title: str | None = None
```

will generate a chunk like this:
```json
"Book": {
    "properties": {
        "title": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Title"
        }
    },
    "title": "Book",
    "type": "object"
}
```

`"type": "null"` is not a valid data type in OpenAPI 3.0.2.

From [here](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md):
```
null is not supported as a type (see [nullable](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#schemaNullable) for an alternative solution).
```
This language is removed from the OpenAPI 3.1.0 spec [here](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md).

To support nullable values in 3.0.2, `nullable` should be used, like this:
```json
{
    "type": "string",
    "nullable": true
}
```

I've also found issues with nested lists in schemas. This won't generate a valid 3.0.2 schema, because it doesn't support nested arrays:
```python
class Test(Schema):
    ranks: list[tuple[conint(gt=0), confloat(ge=0, le=1)]]
```

We've been using [this package](https://github.com/python-openapi/openapi-spec-validator) to validate the OpenAPI files.

**Versions (please complete the following information):**
 - Python version: 3.10
 - Django version: 4.2
 - Django-Ninja version: 1.0.0rc
 - Pydantic version: 2.5



Discussion:

Patch:
diff --git a/ninja/openapi/schema.py b/ninja/openapi/schema.py
index 69d540b..78e5a8a 100644
--- a/ninja/openapi/schema.py
+++ b/ninja/openapi/schema.py
@@ -38,7 +38,7 @@ class OpenAPISchema(dict):
         extra_info = api.openapi_extra.get("info", {})
         super().__init__(
             [
-                ("openapi", "3.0.2"),
+                ("openapi", "3.1.0"),
                 (
                     "info",
                     {


Test patch:
diff --git a/tests/test_openapi_extra.py b/tests/test_openapi_extra.py
index 3f9bd81..0e70bbe 100644
--- a/tests/test_openapi_extra.py
+++ b/tests/test_openapi_extra.py
@@ -37,7 +37,7 @@ def test_openapi_extra():
     schema = api.get_openapi_schema()
 
     assert schema == {
-        "openapi": "3.0.2",
+        "openapi": "3.1.0",
         "info": {"title": "NinjaAPI", "version": "1.0.0", "description": ""},
         "paths": {},
         "components": {"schemas": {}},