tomnvt / curl2swift Goto Github PK
View Code? Open in Web Editor NEWCommand line tool for transforming a cURL request to Swift code
Command line tool for transforming a cURL request to Swift code
Instead of having to have a cURL copied in the clipboard, add option --curl
which will accept the cURL as its value.
When response has sub-model, s
is removed from its key and the result is used as the sub-models name. s
should be removed only in the case, when the sub-model is a list.
Also, the sub-model names should be capitalised.
Example of currently generated code:
struct Response: Codable {
let coord : coord?
let weather : [weather]?
let base : String?
let main : main?
let visibility : Int?
let wind : wind?
let clouds : cloud?
let dt : Int?
let sys : sy?
let timezone : Int?
let id : Int?
let name : String?
let cod : Int?
enum CodingKeys: String, CodingKey {
case coord = "coord"
case weather = "weather"
case base = "base"
case main = "main"
case visibility = "visibility"
case wind = "wind"
case clouds = "clouds"
case dt = "dt"
case sys = "sys"
case timezone = "timezone"
case id = "id"
case name = "name"
case cod = "cod"
}
}
struct sy: Codable {
let type : Int?
let id : Int?
let country : String?
let sunrise : Int?
let sunset : Int?
enum CodingKeys: String, CodingKey {
case type = "type"
case id = "id"
case country = "country"
case sunrise = "sunrise"
case sunset = "sunset"
}
}
struct cloud: Codable {
let all : Int?
enum CodingKeys: String, CodingKey {
case all = "all"
}
}
struct wind: Codable {
let speed : Double?
let deg : Int?
enum CodingKeys: String, CodingKey {
case speed = "speed"
case deg = "deg"
}
}
struct main: Codable {
let temp : Double?
let feelsLike : Double?
let tempMin : Int?
let tempMax : Double?
let pressure : Int?
let humidity : Int?
enum CodingKeys: String, CodingKey {
case temp = "temp"
case feelsLike = "feels_like"
case tempMin = "temp_min"
case tempMax = "temp_max"
case pressure = "pressure"
case humidity = "humidity"
}
}
struct weather: Codable {
let id : Int?
let main : String?
let description : String?
let icon : String?
enum CodingKeys: String, CodingKey {
case id = "id"
case main = "main"
case description = "description"
case icon = "icon"
}
}
struct coord: Codable {
let lon : Double?
let lat : Double?
enum CodingKeys: String, CodingKey {
case lon = "lon"
case lat = "lat"
}
}
where
struct coord: Codable {
should be
struct Coord: Codable {
and
struct sy: Codable {
should be
struct Sys: Codable {
When URL contains multiple query params, they are set one by one, so only the last call takes effect.
set(.queryParams(["q": "prague"]))
set(.queryParams(["appid": "theAppID"]))
set(.queryParams(["units": "metric"]))
Instead it should be called once, with all query params in one dictionary
set(.queryParams(["q": "prague", "appid": "theAppID", "units": "metric"]))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.