Skip to content

[BUG] OpenAPI type names of types in unknown context #6

@bauer-andreas

Description

@bauer-andreas

Describe the bug
When retrieving the type name via the ApodiniTypeInformation framework of a type which is e.g. declared in a function, the OpenAPI doesn't support those as the type name includes characters which are disallowed in OpenAPI schema references.

To Reproduce
Given the example of (assuming this lies in a target name ExampleTarget):

struct OuterTest {
    static func test() {
        struct Test {}

        print(String(reflecting: Test.self))
    }
}

OuterTest.test()

it will print the string ExampleTarget.OuterTest.(unknown context at $109f9c144).(unknown context at $109f9c14c).Test.

ApodiniTypeInformation will create a TypeName which the type Test, target name ExampleTarget and the nested type (unknowncontextat$109f9c144) and (unknowncontextat$109f9c14c).

OpenAPI will just use the concatenation of those when creating a schema entry. This is problematic when trying to reference it, as the type name contains the illegal character (, ) and $.

Expected behavior

It is not entirely clear what the best solution is. One might simple replace those illegal characters, but then we still have an unstable type name (the hex digits change for every compilation step). If we just remove those unknown context entries, it might result in a name collision with a type with the same name defined on the level without those "context" levels or with a type name placed in another function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions