-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Description
The manual generation command swift package generate-code-from-openapi
fails when the package in question contains more than one target that doesn't contain a configuration or spec file.
In 1.7.0 it would skip targets that didn't define a configuration or spec file. In 1.10.0 it fails. Did something change intentionally to force this behavior?
The outcome is not ideal because I want to have different targets, some with code gen, others without any--not to mention having a test target.
In earlier versions (tested against 1.7.0):
Considering target 'AppStoreConnectTests':
- Trying OpenAPI code generation.
- Stopping because target isn't configured for OpenAPI code generation.
Considering target 'AppStoreConnect':
- Trying OpenAPI code generation.
- Stopping because target isn't configured for OpenAPI code generation.
Failure in 1.10.0
Considering target 'AppStoreConnectTests':
- Trying OpenAPI code generation.
- OpenAPI code generation failed with error.
error: Issues with required files:
If this is new expected behavior, can the manual generation example projects be updated with instructions on how to skip a target?
Reproduction
Modify the manual-generation-package-plugin-example with the following:
- Add another directory in Sources named Target2
- Add an empty Swift file
- Modify the package file to include the new target, and bump the generator to 1.10.0.
let package = Package(
name: "manual-generation-package-plugin-example",
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .visionOS(.v1)],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", from: "1.10.0"),
.package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.7.0"),
.package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
],
targets: [
.executableTarget(
name: "CommandPluginInvocationClient",
dependencies: [
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
.product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
]
),
.target(name: "Target2")
]
)
manual-generation-package-plugin-example % swift package generate-code-from-openapi
Result:
Considering target 'Target2':
- Trying OpenAPI code generation.
- OpenAPI code generation failed with error.
error: Issues with required files:
- No config file found in the target named 'Target2'. Add a file called 'openapi-generator-config.yaml' or 'openapi-generator-config.yml' to the target's source directory. See documentation for details.
- No OpenAPI document found in the target named 'Target2'. Add a file called 'openapi.yaml', 'openapi.yml' or 'openapi.json' (can also be a symlink) to the target's source directory. See documentation for details..
Package version(s)
manual-generation-package-plugin-example % swift package show-dependencies
.
├── swift-openapi-generator<https://github.com/apple/[email protected]>
│ ├── swift-algorithms<https://github.com/apple/[email protected]>
│ │ └── swift-numerics<https://github.com/apple/[email protected]>
│ ├── swift-collections<https://github.com/apple/[email protected]>
│ ├── openapikit<https://github.com/mattpolzin/[email protected]>
│ │ └── yams<https://github.com/jpsim/[email protected]>
│ ├── yams<https://github.com/jpsim/[email protected]>
│ └── swift-argument-parser<https://github.com/apple/[email protected]>
├── swift-openapi-runtime<https://github.com/apple/[email protected]>
│ └── swift-http-types<https://github.com/apple/[email protected]>
└── swift-openapi-urlsession<https://github.com/apple/[email protected]>
├── swift-openapi-runtime<https://github.com/apple/[email protected]>
│ └── swift-http-types<https://github.com/apple/[email protected]>
├── swift-http-types<https://github.com/apple/[email protected]>
└── swift-collections<https://github.com/apple/[email protected]>
Expected behavior
The manual generation procedure should allow a package to have targets that are not intended to have generation executed on.
Sure, I can manually delete the other targets, modify the package file, run the generation, then undo my changes, but, it seems like something is off and unanticipated here.
I didn't catch anything in the release notes to indicate this is expected.
Environment
% swift -version
swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0
Additional information
No response