GithubHelp home page GithubHelp logo

moya / moya Goto Github PK

View Code? Open in Web Editor NEW
15.0K 15.0K 2.0K 17.85 MB

Network abstraction layer written in Swift.

Home Page: https://moya.github.io

License: MIT License

Swift 98.15% Ruby 1.15% Shell 0.49% Objective-C 0.21%
alamofire hacktoberfest networking reactiveswift rxswift swift

moya's People

Contributors

andrewsb avatar aschuch avatar ashfurrow avatar basthomas avatar colinta avatar devxoul avatar ealeksandrov avatar edwardvalentini avatar esttorhe avatar f-meloni avatar freak4pc avatar jeehut avatar jrheaton avatar justinmakaila avatar leoneparise avatar lucianopalmeida avatar nanoxd avatar neonichu avatar ohkanghoon avatar orta avatar peagasilva avatar pedrovereza avatar pmairoldi avatar scottrhoyt avatar sd10 avatar sunshinejr avatar swizzlr avatar ufosky avatar wangshengjia avatar wattson12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moya's Issues

Unable to use Moya with CocoaPods

Thanks for this great work, but I can't use that because when i run bundle install, it show following message

Bundler could not find compatible versions for gem "xcodeproj":
  In Gemfile:
    cocoapods (>= 0) ruby depends on
      xcodeproj (~> 0.20.2) ruby

    xcodeproj (0.20.1)

Compile-time safe way to restrict API endpoint calls

So this is a tough one that I need to figure out an abstraction for. The basic gist is as follows: You set up a MoyaProvider with a bunch of endpoints. Cool, right? Except as of this moment, you access the API like this:

let provider = MoyaProvider(endpoints: [
                    Endpoint(URL: "http://rdjpg.com/300/200/", sampleResponse: {
                        /* doesn't matter */
                    })
                ])

...

provider.request("http://rdjpg.com/300/200/", completion: { (object: AnyObject?) -> () in
    ...
})

Not cool – let's avoid stringly-typedness in this library.

Is there a way to provide a compile-time check that the endpoint actually exists? Can we set up some sort of enum or token or something that you pass in when you create the endpoint, and then reuse that token later on when calling the API? It needs to be something accessible by both whoever sets up the API at app launch, likely the app delegate, and anyone else who wants to access it (view controllers, network layers, whoever).

It's tricky since I want a clear separation of this library and the app code. Since each app has a different API, this abstraction – whatever it ends up being – needs to be something defined in app code, but is used by the library.

So I need a thing that someone using this library creates, uses to register the endpoint, then uses somewhere else in order to access the API. Any thoughts?

Delay in stubs

It would be sweet if there were a way to randomly or deterministically add a short delay to stub request returns to make it a little more "real".

Use of RAC is Incorrect

So right now, we send the request when the request method is called. That is no the ReactiveCocoa way. We should be returning a multicasted signal that sends the request when it is first subscribed to, like this.

Distribute to AppStore

I use this framework with CocoaPods, but I can't install my app on my device via OTA install (use Fabric).

And I try to submit to iTunes Connect, I got this message.

Dear developer,

We have discovered one or more issues with your recent delivery for "". To process your delivery, the following issues must be corrected:

This bundle is invalid - The file extension must be .zip.

Any idea?

Custom ParameterEncodings

I have been working with this framework on iOS and am having a compile issue when adding custom parameterEncodings. I was wondering if you could help me out.

My EyeQEndPoints enum does not implement URLRequestConvertible which I believe is ok.

I declare the custom closure as follows:

let xmlParameterEncoding:(URLRequestConvertible, [String: AnyObject]?) -> (NSURLRequest, NSError?) = {(URLRequest, parameters) in {

//this is just to get things working
return (NSURLRequest.URLRequest, nil)
}

In the endpointsClosure, I set the custom closure:

let endpointsClosure = { (target: EyeQEndPoints, method: Moya.Method, parameters: [String: AnyObject]) -> Endpoint in
return Endpoint(URL: url(target), sampleResponse: EndpointSampleResponse.Success(200, target.sampleData), method: method, parameters: parameters, parameterEncoding: .Custom(xmlParameterEncoding))
}

The compiler throws an error on .Custom(xmlParameterEncoding) of

error: type 'URLRequestConvertible' does not conform to protocol 'URLRequestConvertible'
return Endpoint(URL: url(target), sampleResponse: EndpointSampleResponse.Success(200, target.sampleData), method: method, parameters: parameters, parameterEncoding: .Custom(xmlParameterEncoding))

Thanks for your help.

Inline testing providers

right now a test suite doing some networking looks like:

    beforeSuite { () -> () in
        // Force provider to stub responses
        APIKeys.sharedKeys = APIKeys(key: "", secret: "")
        Provider.sharedProvider = Provider.StubbingProvider()
    }

    afterSuite { () -> () in
        // Reset provider
        APIKeys.sharedKeys = APIKeys()
        Provider.sharedProvider = Provider.DefaultProvider()
    }

    it("returns some data") {
        setDefaultsKeys(nil, nil)

        var called = false
        XAppRequest(.Auctions).subscribeNext({ (object) -> Void in
            called = true
        })

        expect(called).to(beTruthy())
    }

    ... etc

This is fine, and it goes and access pre-rendered stubs etc. I'd like some choice, and to allow making something like this (excusing broken syntax):

  let networkProvider = Provider.runtimeProvider()
  beforeSuite { () -> () in
      Provider.sharedProvider = networkProvider
  }

  afterSuite { () -> () in
      Provider.sharedProvider = Provider.DefaultProvider()
  }

  it("returns some data") {

      var called = false

      networkProvider.responseString(.Auctions) {
        return "{ 'foo':'bar' }"
      }

      XAppRequest(.Auctions).subscribeNext({ (object) -> Void in
          called = true
      })

      expect(called).to(beTruthy())
  }

with maybe the potential of returning strings, json objects and data?

test network failures

Right now you can only stub successes, but if your view controller reacts to failures, there is no way to stub that.

Swagger Spec -> Moya Target Generator

I may end up doing this in anger, so I'm dropping a note here in case anyone else is interested. Probably a separate project? It uses mustache templates so how hard can it be?!

MoyaErrorDomain must be public

When choosing to use Moya as a submodule rather than copy its files into a project, MoyaErrorDomain is unusable outside Moya since it's private by default.

Sample App

As @orta suggested, it'd be awesome to have a sample application demonstrating real-world use of Moya with the GitHub API.

NSURLSessions something something

This is a new API as of iOS 7, and to be honest, I haven't taken a look at it yet. It could be really useful or something. Let's find out.

Logo

All the projects nowadays need a cool, edgy logo. Not a high priority, but when it comes to logos, I only trust the best.

Provide non-ReactiveCocoa interface

The main interface can still use RACSignals, but we should have an extension for the MoyaProvider class that allows developers to opt for callback blocks.

Allow specification of parameter encoding

Alamofire supports four different parameter encodings. Basically, we just need to expose those options to the Endpoint class. I'd like to do that without exposing the internals of Alamofire itself, though.

Documentation

Sorely missing. Now that eidolon is at a 1.0, I should have enough real-world experience to document, in detail, the different use cases and features of Moya.

Alamofire submodule will not update

Looks like it was added with ssh key for a submodule. I don't use ssh. Can it be added by http?

Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Clone of '[email protected]:Alamofire/Alamofire.git' into submodule path 'submodules/Alamofire' failed

Keep track of in-flight requests

This will be a key component after #1 is completed. For example, if a request is made to an in-flight request, we can return the promise or signal or whatever associated with that response.

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.