Skip to content

[Swift] Apple's openapi generator incompatability. #457

@marknefedov

Description

@marknefedov

Preflight checklist

Ory Network Project

No response

Describe your problem

Hi, it looks like OpenAPI schemas that are used for SDK generation are slightly incomplete.
Specificaly: https://github.com/ory/sdk/blob/master/spec/kratos/v25.4.0.json I have not tested other yet.

I'm trying to produce Swift client for Kratos using https://github.com/apple/swift-openapi-generator, but getting an error of spec validation:
openapi.json: error: Inconsistency encountered when parsing sessionToken in Document.paths['/self-service/settings'].post.security: Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary.
Error: C:/Users/.../openapi.json: error: Inconsistency encountered when parsing sessionToken in Document.paths['/self-service/settings'].post.security: Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary.
That looks valid, as in securitySchemes only oryAccessToken is described. If I add sessionToken scheme, client generation proceeds.

https://ory-community.slack.com/archives/C010F7Z4XM1/p1766256918524329?thread_ts=1766238359.622319&cid=C010F7Z4XM1

Second issue is 'duplicated' nullTime, specifically schema contains 'nullTime' and 'NullTime' in idiomatic mode, it results in name collision in Apple OAPI generator. So it must be turned off for now. apple/swift-openapi-generator#854 (comment)

While apple's openapi generator does not produce very pleasant API and is usually used as a plugin inside codebase, it supports being used as standalone generator. And fixing this issue will be a great first step for the swift support.

Describe your ideal solution

Fix the schema definition.

Workarounds or alternatives

Copy schema from your repo and edit it.
Using third party swift client generator.

Version

v25.4.0

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    featNew feature or request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions