swagger-api / swagger-api/swagger-codegen

Swift How to convert data into Modal

Open
#2,424 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Swift help wanted
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

import UIKit
import SwaggerClient

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        ConfigsAPI.v1ConfigsGet { (data, error) -> Void in

            print(data is Configer)

            print(data)
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

Output as:

false
Optional({
    androidPlayer =     {
        playerList =         (
            default,
            ijk
        );
        version = 4;
    };
    autoCache =     {
        version = 7;
        videoNum = 10;
    };
    campaignInDetail =     {
        actionUrl = "http://www.wandoujia.com/eyepetizer";
        available = 0;
        category = "\U97f3\U4e50";
        imageUrl = "http://img.wdjimg.com/image/video/78a2f9836b9a05fcb3f44a75d18af50f_540_540.jpeg";
        showType = bindWithCategory;
        version = 7;
    };
    campaignInFeed =     {
        actionUrl = "http://www.wandoujia.com/eyepetizer/collection.html?name=bodyguard&ineyepetizerapp=true&shareable=true";
        available = 0;
        imageUrl = "http://img.wdjimg.com/image/video/03b529064b3b27f2e033316a2bf0cefe_0_0.jpeg";
        version = 33;
    };
    consumption =     {
        display = 1;
        version = 3;
    };
    firstLaunch =     {
        showFirstDetail = 0;
        version = 1;
    };
    issueCover =     {
        issueLogo =         {
            adapter = 0;
            weekendExtra = "http://img.wdjimg.com/image/video/6ac75af6fd23b286eafdb3798072a15c_0_0.jpeg";
        };
        version = 2;
    };
    log =     {
        playLog = 0;
        version = 6;
    };
    push =     {
        endTime = 22;
        message = "\U4eca\U5929\U7684\U65e5\U62a5\U5df2\U51c6\U5907\U597d\Uff0c\U8bf7\U4eab\U7528\Uff01";
        startTime = 9;
        version = 18;
    };
    pushInfo =     {
        normal =         {
            endTime = 43200;
            message = "\U4eca\U5929\U7684\U65e5\U62a5\U51c6\U5907\U597d\U4e86";
            startTime = 32400;
        };
        version = 1;
        weekendExtra =         {
            endTime = 73800;
            message = "\U53f7\U5916\U53f7\U5916\Uff01\U65b0\U9c9c\U523a\U6fc0\U7684\U5468\U672b\U53f7\U5916\U6765\U5566\Uff01";
            startTime = 63000;
        };
    };
    reply =     {
        on = 1;
        version = 1;
    };
    shareTitle =     {
        qzone = "\U5f00\U773c";
        version = 2;
        wechatMoments = "\U5f00\U773c";
        weibo = "\U5f00\U773c";
    };
    startPage =     {
        actionUrl = "";
        imageUrl = "http://img.wdjimg.com/image/video/5473210f7a08979f70d351b91218ca10_0_0.jpeg";
        version = 54;
    };
    startPageAd =     {
        actionUrl = "eyepetizer://webview/?title=Adidas&url=http%3A%2F%2Fe.cn.miaozhen.com%2Fr%2Fk%3D2018684%26p%3D6zxVc%26dx%3D0%26rt%3D2%26ns%3D__IP__%26ni%3D__IESID__%26v%3D__LOC__%26ro%3Dsm%26mo%3D__OS__%26m0%3D__OPENUDID__%26m0a%3D__DUID__%26m1%3D__ANDROIDID1__%26m1a%3D__ANDROIDID__%26m2%3D__IMEI__%26m4%3D__AAID__%26m5%3D__IDFA__%26m6%3D__MAC1__%26m6a%3D__MAC__%26vo%3D376ac5837%26vr%3D2%26o%3Dhttp%253A%252F%252Foriginals.adidasevents.com%252Fmar%252Fnmd";
        adTrack =         (
        );
        blurredImageUrl = "http://img.wdjimg.com/image/video/adc7ef6f4bb443750d5ee9b4bd15eafd_0_0.jpeg";
        canSkip = 1;
        countdown = 1;
        displayTimeDuration = 3;
        endTime = 1458230340000;
        imageUrl = "http://img.wdjimg.com/image/video/7c3ebdbe02cd7f041baa9674e52631c7_0_0.jpeg";
        startTime = 1458144000000;
        version = 35;
    };
    version = 176;
})

What happened? How do I call the properties of the type I set?I remember before I was able to ah

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ConfigsAPI.v1ConfigsGet callback in the supplied ViewController example and inspect the generated Configer type in SwaggerClient. Compare the callback's data value with the printed response and determine why it is not recognized as Configer. Done means the expected model properties can be accessed from the returned value.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
api, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.