apple / swift-openapi-generator

Generate Swift client and server code from an OpenAPI document.
https://swiftpackageindex.com/apple/swift-openapi-generator/documentation
Apache License 2.0
1.21k stars 87 forks source link

More config options, including pointing to spec file location #532

Closed edonv closed 2 months ago

edonv commented 2 months ago

Motivation

I’m currently working on a project that requires the spec live in its own repo, as it’s an api spec for a different project. Then, I’d like to be able to generate Swift code for it, looking at that other repo’s spec.

Proposed solution

Not sure the best way to do it. Maybe it’s to just run the CLI plugin and have it generate static code for its own library, or I could add the spec repo as a git submodule use the plugin normally. Either way, I’d like to have it expose code a la the “Curated client library” example.

So I think it could be beneficial to be able to enter the relative path of the spec file, in case the spec needed to be referenced as a submodule in the primary repo.

Alternatives considered

No response

Additional information

No response

czechboy0 commented 2 months ago

Hi @edonv,

I recommend using a symlink from Sources/MyTarget/openapi.yaml -> <elsewhere in the repo>, that allows you to use e.g. an OpenAPI doc from a git submodule.

edonv commented 2 months ago

Thought I saw that as a possibility somewhere but couldn't find it again. Thanks! I'll give that a try.

czechboy0 commented 2 months ago

@edonv That's how I use it in most projects, so if it doesn't work that'd be considered a bug.

edonv commented 2 months ago

Worked great as a symlink locally, haven't tried yet via submodule. But I'd imagine should be fine!

czechboy0 commented 2 months ago

Great, closing then.