Question on scaling
jbehrens94 opened this issue · 3 comments
Hi all, thanks for answering my question a while back on Fluent, @0xTim and @MahdiBM.
I have a broader question about the usage of the OpenAPI Vapor package. If I were to build a bigger OpenAPI document over time, the implementation of the Handler would grow quite fast. What would your suggestion be on managing this scaling up?
I think this question be best asked on the swift-openapi-generator repository since the maintainers there would know the answer to your question better.
As far as I'm aware, you can break down your openapi document to multiple different documents.
If you want to break down your code into smaller pieces, you can also create multiple SwiftPM targets each with their own openapi document (it's generally a good idea to create more targets for both debug-build performance and clean-code reasons)
Interesting, @MahdiBM. Would you suggest then to create multiple instances of a Client like this?
// Create an instance of your handler type that conforms the generated protocol
// defininig your service API.
let handlerTypes: [APIProtocol] = [
PantryHandler() // from Pantry package
RecipeHandler() // from Recipe package
]
// Call the generated function on your implementation to add its request
// handlers to the app.
try handlerTypes.forEach { try $0.registerHandlers(on: transport) }
I think that makes sense to me