2017-09-18 8 views
0

私はswaggerで私のapi文書を持っています。私はPHPとjavaのオプションをClient sdkドロップダウンでユーザに提供したいと思います。以下は私のコードです。swaggerUIでClient sdkのDropDownを表示

public void ConfigureServices(IServiceCollection services) 
     { 
      services.AddMvc(); 

      services.AddSingleton(provider => Configuration); 
      services.AddTransient<IRegistrationRepository, ServiceUtilities>(); 
      services.AddTransient<IClientServiceConnector, ClientServiceValidation>(); 
      services.AddTransient<IEmailSender, EmailSender>(); 

      services.AddSwaggerGen(c => 
      { 
       c.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info 
       { 
        Title = "Onboarding API", 
        Version = "V1", 
        Description = "API to generate lead and return the url", 
        TermsOfService = "Please see terms and conditions", 
        Contact = new Swashbuckle.AspNetCore.Swagger.Contact {Name = "teggggrap",Email = "[email protected]",Url= "https://www.dd.com.au/" } 
       }); 

       var basePath = PlatformServices.Default.Application.ApplicationBasePath; 
       var xmlPath = Path.Combine(basePath, "gf.RegistrationApplication.xml"); 
       c.IncludeXmlComments(xmlPath); 
      }); 

      services.AddCors(options => 
      { 
       options.AddPolicy("AllowAll", policy => 
       { 
        policy.AllowAnyOrigin(); 
        policy.AllowAnyHeader(); 
        policy.AllowAnyMethod(); 
       }); 
      }); 
     } 
+0

あなたの質問はあいまいです。 Swaggerで生成されたメタデータでは、特定の関数(get、post、deleteなど)を実行する前に、これらのオプション(php、java)の1つを選択する必要がありますか? – Usman

+0

APIを消費するクライアントSDKを生成したい。ユーザーがPHP開発者である場合、彼はPHP SDKをダウンロードして使用できます。 – maxspan

答えて

1

APIのコンシューマは、あなたのAPIのクライアントを自分の言語で作成するためにswagger-codegenを生成できます。おそらく自分でホストしたくないかもしれませんが、ユーザにhttps://editor.swagger.io/への指示を与えることで、API仕様をアップロードしそこから生成することができます。

関連する問題