Divide the yaml generation into several controllers
Question
I have one opeanapi file, in this file I have many tags, and one of tags have admin tag (access only for admin), but when xcode generate it in one file I don't know how use divide for this controller
Hi @gulivero1773,
you have two options here:
- Split the implementation across multiple files, each having an
extension MyHandlerthat adds a few more operations. - Split the implementation across multiple Swift modules, by using filtering and only generating a subset of the API in each module, and then registering the multiple API handlers onto the same server. More complicated setup, but allows for better modularization.
Maybe example you know for 2?
Not an exact example, but this one shows having multiple modules, all using OpenAPI, and a symlink to a single copy in the repo, each with a different config file: https://github.com/apple/swift-openapi-generator/tree/main/Examples/shared-types-client-server-example
And in each config file you'd filter to a different subset of the operations/tags that you want to include there.
Maybe example you know for 2?
I have an example that uses filtering. Might not be the best but it works. https://github.com/Altered-Tech/swift-petstore-oas
Has the openapi spec in Sources/ then different targets for each operationId. I was experimenting with creating an aws lambda for each operation.
Thanks @alteredtech - yes that's exactly the setup I had in mind.
Thank you, this - https://github.com/Altered-Tech/swift-petstore-oas help me, but if my package (AddPet and GetPetById) have shared service or repository, for me It's hard to understand how to do it better.
https://github.com/Altered-Tech/swift-petstore-oas show example for code if it not use shared code