Skip to content

API: mixing additionalProperties with properties #3901

@commonism

Description

@commonism

Describe your question/

The OpenAPI description document specifies schemas which mix named properties and additionalProperties:{}.
While this is valid, it severely impacts the choice/quality of clients being able to interface the API.

Relevant infos
I author/use aiopenapi3, a python3 OpenAPI client/validator. aiopenapi3 is making use of pydantic to take care of the Schema things, even additionalProperties: True -the json schema default- is a problem (to pydantic or any other Validator).

Additionally the named property of a schema (PromptChallengeResponseRequest) with additionalProperties is used as a propertyName in a discriminated union (FlowChallengeResponseRequest).

Removing the additionalProperties from ValidationError & PromptChallengeResponseRequest allows me to parse the description document.

import aiopenapi3.plugin
from aiopenapi3 import OpenAPI

class AuthentikDocument(aiopenapi3.plugin.Document):
    def parsed(self, ctx):
        for c in ["ValidationError","PromptChallengeResponseRequest"]:
            if "additionalProperties" in ctx.document["components"]["schemas"][c]:
                del ctx.document["components"]["schemas"][c]["additionalProperties"]
        return ctx

def test_authentik_HEAD():
    api = OpenAPI.load_sync("https://raw.githubusercontent.com/goauthentik/authentik/main/schema.yml",
                            plugins=[AuthentikDocument()])

I do not know any better than pydantic, I have to use it.
Therefore I'd be glad if you could have a look in getting the description document to use the subset of OpenAPI/json schema which allows using it with pydantic/aiopenapi3.

And I propose to test the OpenAPI description document with a bunch of clients/validators/generators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions