def test_optional_get_schema():
    "This tests that enum that is only used in GET operation puts a that enum into schema.components"
    schema = api.get_openapi_schema()

    op = schema["paths"]["/api/optional2"]["get"]
    print(op)
    assert op["parameters"][0]["schema"]["anyOf"] == [
        {"$ref": "#/components/schemas/ExtraEnum"},
        {"type": "null"},
    ]

    components = schema["components"]["schemas"]
    print(components)
    assert "ExtraEnum" in components
This tests that enum that is only used in GET operation puts a that enum into schema.components
tests/test_enum.py