edjCase / JsonRpc

Json Rpc Router for Asp.Net Core
MIT License
141 stars 42 forks source link

Integration with Swagger #101

Closed smaktacular closed 3 years ago

smaktacular commented 3 years ago

Hi @Gekctek,

do you see any chance to have the routes/params/responses generated, being document by swagger?

smaktacular commented 3 years ago

Just saw the extenssion methods in the code.

Eternal-ll commented 2 years ago

UPD3. Found it. I missed EdjCase.JsonRpc.Router.Swagger AddJsonRpcWithSwagger()

What kind of extension did you saw? I cant generate controllers on swagger that inherited from RpcController

UPD. Looks like i misunderstand something. I want to try to generate both rest and jsonrpc actions. [Route("api/[controller]")] [RpcRoute("/api/jsonrpc/[controller]")]

Is it possible? Getting this error:

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1] An unhandled exception has occurred while executing the request. Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Ambiguous HTTP method for action - PayGate.API.Controllers.TinkoffController.Ok (PayGate.API). Actions require an explicit HttpMethod binding for Swagger/OpenAPI 3.0 at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable1 apiDescriptions, SchemaRepository schemaRepository) at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable1 apiDescriptions, SchemaRepository schemaRepository) at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

UPD2: Maximum i got is generate actions as rest

public class TinkoffController : RpcController { /// <summary> /// Test /// </summary> /// <param name="test"></param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> [HttpPost("api/[controller]/Test")] [ProducesResponseType(StatusCodes.Status200OK)] public async Task<string> Test(int test) { throw new NotImplementedException(); } .... }

image