[Swift] Apple's openapi generator incompatability.

Open
#457 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
openapi, swift
Domain
api, tooling

Research direction

Start with spec/kratos/v25.4.0.json and inspect the security declaration for POST /self-service/settings, especially sessionToken and components.securitySchemes. Then review the nullTime and NullTime schemas and validate the corrected schema with Apple's swift-openapi-generator; done means both reported incompatibilities are resolved without manual schema edits.

Written by the indexing model from the issue text.

Description

feat
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. https://github.com/apple/swift-openapi-generator/issues/854#issuecomment-3678025561

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

Dominant language
PHP
Stars
178
Forks
96
Avg merge
6d 23h
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ory/sdk

All issues in ory/sdk

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.