Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Specify Api Routes #5

Closed
prefect42 opened this issue Mar 9, 2017 · 6 comments
Closed

Question: Specify Api Routes #5

prefect42 opened this issue Mar 9, 2017 · 6 comments

Comments

@prefect42
Copy link

Hey yonaskolb!

First off, really great project. I love SwagGen and the fact that I can now use a native app generating my models and requests plus using Stencil which I really love.

A quick question: Is it possible to specify only the routes or models which should be generated?
Similar to Swagger Codegens -Dmodels {opts}, -Dapis {opts} flags?

That would be great!
Keep up the good work.

Kind regards

PS: Stencil has been updated and now allow % elif %. Would be great if you could update the dependencies. Perhaps even not constraining them to an exact version but e.g. specifying the major version ;-)

@yonaskolb
Copy link
Owner

Thanks for the kind words @prefect42!

At the moment, no there isn't a way to only generate a subset of the spec.
In terms of Stencil, I actually use my own fork that adds something I was looking for, and the pull request I made hasn't been approved yet stencilproject/Stencil#85
I can look at rebasing my fork though to upgrade

@prefect42
Copy link
Author

No worries. I script myself a filter.

One more thing: Currently a file is created for every method of an API Controller. Is that really necessary. Would be great if the Extensions to the controller could be generated all in the same file. If this is not to your liking this could be made a parameter.

Your project is really young, but I am very glad I found it.

@yonaskolb
Copy link
Owner

Yes, in the default template all the operations are generated as seperate files, but you can easily generate them in one file if you change the request.swift destination in the template.yml file from:

"Requests{% if tag %}/{{ tag|upperCamelCase }}{% endif %}/{{ operationId|upperCamelCase }}.swift"

to

Requests.swift

And then in the request.swift file wrap the relevant code in a

{% for operation in operations %}
...
{% endfor %}

And then reference all the operation properties with operation.

That's the advantage of having a flexible template configuration, instead of the hardcoded files in Swagger Codegen

@prefect42
Copy link
Author

Awesome 🎉
I am glad I asked ;-)

@yonaskolb
Copy link
Owner

Just a note, you would also have to remove context: operations from the request file in template.yml to get them generating in 1 file

@yonaskolb
Copy link
Owner

@prefect42, the Stencil dependancy has been updated so feel free to use the new {% elif %} tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants