Code Monkey home page Code Monkey logo

Comments (9)

dangthaison91 avatar dangthaison91 commented on May 17, 2024

Update: I changed template.yml to this:

- path: request.swift
  context: tags
  destination: "Sources/Requests/{{ name|upperCamelCase }}.swift"

then update request.swift template:

public enum {{ operation.operationId|upperCamelCase }} {

    public static let service = APIService<Response>(id: "{{ operationId }}", tag: "{{ tag }}", method: "{{ method|uppercase }}", path: "{{ path }}" ... {% endif %})

To:

{% for operation in operations %}

    public enum {{ operation.operationId|upperCamelCase }} {

         public static let service = APIService<Response>(id: "{{ operation.operationId }}", tag: "{{ operation.tag }}", method: "{{ operation.method|uppercase }}", path: "{{ operation.path }}" .. .{% endif %})

{% endfor %}

Can we do it without adding operation. prefix?

from swaggen.

yonaskolb avatar yonaskolb commented on May 17, 2024

Hi @dangthaison91
I'm glad you're getting some good use out of it.

If you'd like to define an operation without always typing operation. you can make it an include:

{% for operation in operations %}
  {% include "Includes/operation.yml" using operation %}
{% endfor %}

And then move the relevant operation code to Includes/operation.yml" within the template. This is enabled by some changes to include` I made to my fork of Stencil stencilproject/Stencil#114

from swaggen.

yonaskolb avatar yonaskolb commented on May 17, 2024

It would be great if you could submit your custom template in a PR when you're done! It can be added to Templates/Swift-Moya

from swaggen.

yonaskolb avatar yonaskolb commented on May 17, 2024

Yeah, I have similar feelings to you about the Swagger Codegen Java project. I've also made quite a few PR's and also got sick of their java interface, so that was the main reason I actually created this

from swaggen.

dangthaison91 avatar dangthaison91 commented on May 17, 2024

Thank you so much @yonaskolb. I'd be happy to submit my PR when I've done.

from swaggen.

yonaskolb avatar yonaskolb commented on May 17, 2024

Hi @dangthaison91, how's your Moya template going? Anything you'd feel comfortable submitting?

from swaggen.

dangthaison91 avatar dangthaison91 commented on May 17, 2024

Hi @yonaskolb , I already created my own Moya template but having some problems while generating Models to use with Realm. I used in some company's project but sometimes I have to manual edit/fix errors.

I pushed it to my folk repo, you can get it here: https://github.com/dangthaison91/SwagGen/tree/master/Templates/Swift-Moya

I have created an example but need to remove private stuffs before making it public.

from swaggen.

yonaskolb avatar yonaskolb commented on May 17, 2024

@dangthaison91 Just you you know I've released 0.6.0. Check the release notes https://github.com/yonaskolb/SwagGen/releases/tag/0.6.0
You might want to merge that into your branch and see if it still works or if it fixes anything for you.
One thing that has changed that I know will affect you is within a template tags has been renamed to operationsByTag. tags is now just a list of tag names

from swaggen.

dangthaison91 avatar dangthaison91 commented on May 17, 2024

@yonaskolb Oh, thanks for your reminder. I will check this weekend.

from swaggen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.