Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Oregon
São Paulo
Frankfurt
{JSON}
Swagger
Swagger
๑⁼̴̀ ⁼̴́๑ ‼
https://www.openapis.org/membership/members
/statuses/show/{id}:
get:
description: Retruns a single Tweet
security:
- oauth:
- basic
parameters:
- name: id
in: path
d...
$ wget http://central.maven.org/
maven2/io/swagger/swagger-codegen-cli/
2.2.2/swagger-codegen-cli-2.2.2.jar
$ brew install...
$ swagger-codegen generate
-i swaggerspec.json
-l CsharpDotNet2
-o src
-c config.json
{
"packageName": "Connect.Navi.Clien...
namespace IO.Swagger.Model {
[DataContract]
public class User {
[DataMember(Name="id", EmitDefaultValue=false)]
[JsonPrope...
namespace IO.Swagger.Api
{
public interface IUserApi
{
void CreateUser (User body);
void CreateUsersWithArrayInput (List<U...
namespace IO.Swagger.Client
{
public class ApiClient
{
private readonly Dictionary<String, String> _defaultHeaderMap
= new...
public Object CallApi(String path, RestSharp.Method method,
Dictionary<String, String> queryParams, String postBody,
Dicti...
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
Upcoming SlideShare
Loading in …5
×

XamarinとAWSをつないでみた話

683 views

Published on

CLR/H #clrh104 ~ Xamarin in 札幌 ~ にて発表した資料です。

Published in: Technology
  • Be the first to comment

XamarinとAWSをつないでみた話

  1. 1. Oregon São Paulo Frankfurt
  2. 2. {JSON} Swagger
  3. 3. Swagger
  4. 4. ๑⁼̴̀ ⁼̴́๑ ‼
  5. 5. https://www.openapis.org/membership/members
  6. 6. /statuses/show/{id}: get: description: Retruns a single Tweet security: - oauth: - basic parameters: - name: id in: path description: The numerical ID of the desired status required: true type: string - name: trim_user in: query description: When set to either true, t or 1, each tweet required: false type: string - name: include_my_retweet in: query
  7. 7. $ wget http://central.maven.org/ maven2/io/swagger/swagger-codegen-cli/ 2.2.2/swagger-codegen-cli-2.2.2.jar $ brew install swagger-codegen !
  8. 8. $ swagger-codegen generate -i swaggerspec.json -l CsharpDotNet2 -o src -c config.json { "packageName": "Connect.Navi.Client" }
  9. 9. namespace IO.Swagger.Model { [DataContract] public class User { [DataMember(Name="id", EmitDefaultValue=false)] [JsonProperty(PropertyName = "id")] public long? Id { get; set; } [DataMember(Name="username", EmitDefaultValue=false)] [JsonProperty(PropertyName = "username")] public string Username { get; set; } [DataMember(Name="firstName", EmitDefaultValue=false)] [JsonProperty(PropertyName = "firstName")] public string FirstName { get; set; } [DataMember(Name="lastName", EmitDefaultValue=false)] [JsonProperty(PropertyName = "lastName")] public string LastName { get; set; } /// <summary> /// Gets or Sets Email
  10. 10. namespace IO.Swagger.Api { public interface IUserApi { void CreateUser (User body); void CreateUsersWithArrayInput (List<User> body); void CreateUsersWithListInput (List<User> body); void DeleteUser (string username); User GetUserByName (string username); string LoginUser (string username, string password); void LogoutUser (); void UpdateUser (string username, User body); } public class UserApi : IUserApi { // /// <param name="apiClient"> an instance of ApiClient (optional)</ param> /// <returns></returns>
  11. 11. namespace IO.Swagger.Client { public class ApiClient { private readonly Dictionary<String, String> _defaultHeaderMap = new Dictionary<String, String>(); public ApiClient(String basePath=“http://localhost:8080") { BasePath = basePath; RestClient = new RestClient(BasePath); } /// <summary> /// Makes the HTTP request (Sync). /// </summary> /// <param name="path">URL path.</param> /// <param name="method">HTTP method.</param> /// <param name="queryParams">Query parameters.</param> /// <param name="postBody">HTTP body (POST request).</param> /// <param name="headerParams">Header parameters.</param> /// <param name="formParams">Form parameters.</param>
  12. 12. public Object CallApi(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody, Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, FileParameter> fileParams, String[] authSettings) { var request = new RestRequest(path, method); UpdateParamsForAuth(queryParams, headerParams, authSettings); // add default header, if any foreach(var defaultHeader in _defaultHeaderMap) request.AddHeader(defaultHeader.Key, defaultHeader.Value); // add header parameter, if any foreach(var param in headerParams) request.AddHeader(param.Key, param.Value); // add query parameter, if any foreach(var param in queryParams) request.AddParameter(param.Key, param.Value, ParameterType.GetOrPost); // add form parameter, if any foreach(var param in formParams) request.AddParameter(param.Key, param.Value, ParameterType.GetOrPost); // add file parameter, if any foreach(var param in fileParams) request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, aram.Value.ContentType);

×