OpenAPI generator can't find openapi-generator-config.yaml

(Xcode 15b1)

I'm trying to create a client SDK for a project I'm working on, and would love to leverage the OpenAPI generator to do it. Following the instructions here, I’m running into errors in Xcode 15b1.

In particular, I get “No config found in the target named 'SwiftClientSDK'. Add a file called 'openapi-generator-config.yaml' to the target's source directory,” but my source directory looks like this:

$ tree
.
├── Package.resolved
├── Package.swift
├── Sources
│   └── SwiftClientSDK
│       ├── OpenAPI.yaml
│       ├── SwiftClientSDK.swift
│       └── openapi-generator-config.yaml
└── Tests
    └── SwiftClientSDKTests
        └── SwiftClientSDKTests.swift

My Package.swift:

// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
	name: "SwiftClientSDK",
	platforms:[
		.macOS(.v13), .iOS(.v16), .tvOS(.v16), .watchOS(.v9),
	],
	products:[
		.library(name: "SwiftClientSDK", targets: ["SwiftClientSDK"]),
	],
	dependencies:[
		.package(url: "https://github.com/apple/swift-openapi-generator",		.upToNextMinor(from: "0.1.0")),
		.package(url: "https://github.com/apple/swift-openapi-runtime",			.upToNextMinor(from: "0.1.0")),
		.package(url: "https://github.com/apple/swift-openapi-urlsession",		.upToNextMinor(from: "0.1.0")),
	],
	targets: [
		.target(
			name: "SwiftClientSDK",
			dependencies:[
				.product(name: "OpenAPIRuntime",		package: "swift-openapi-runtime" ),
				.product(name: "OpenAPIURLSession",		package: "swift-openapi-urlsession"),
			],
			plugins:[
				.plugin(name: "OpenAPIGenerator",		package: "swift-openapi-generator")
			]
		),
		.testTarget(name: "SwiftClientSDKTests", dependencies: ["SwiftClientSDK"]),
	]
)

In Xcode, the error looks like this. I don't know the values of ${BUILD_DIR} or ${CONFIGURATION}:


Showing All Messages
working directory:
   /Users/rmann/Projects/Personal/SwiftClientSDK
tool mapping:
   swift-openapi-generator: /${BUILD_DIR}/${CONFIGURATION}/swift-openapi-generator
tool search paths:
   /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
   /Applications/Xcode-beta.app/Contents/Developer/usr/bin
   /bin
   /sbin
   /usr/bin
   /usr/sbin

No config found in the target named 'SwiftClientSDK'. Add a file called 'openapi-generator-config.yaml' to the target's source directory. See documentation for details.
No config found in the target named 'SwiftClientSDK'. Add a file called 'openapi-generator-config.yaml' to the target's source directory. See documentation for details.

Hi @JetForMe,

some things to try:

  • add the openapi.yaml file as well, as the plugin requires both
  • close and reopen the IDE

If it still doesn't work then, please create an issue on Issues · apple/swift-openapi-generator · GitHub

Thanks!

OpenAPI.yaml is in there too, must it be all lower case (I suppose that would definitely matter on Linux)? Is there a way to specify the file paths directly, perhaps in Package.swift (with relative paths)?

Update to add: Quitting Xcode and re-launching seemed to solve the issue. Making the name lowercase did not, by itself.

PS, I've opened FB12333014 requesting that Xcode show generated source code in the Groups & Files navigator.

Update to add: Quitting Xcode and re-launching seemed to solve the issue. Making the name lowercase did not, by itself.

Glad you managed to resolve your issue and thanks for filling the Xcode issue.

Is there a way to specify the file paths directly, perhaps in Package.swift (with relative paths)?

While the underlying CLI does already take the path to the OpenAPI document as an argument, I don't think that's currently possible to express this through the build plugin interface.

2 Likes

Just ran into this issue as well. Restarting Xcode 15 beta solved it.

Please file a feedback on Xcode about that, and post the number here if you can. Thanks!

FB12350095

1 Like