1

As I tried to change one public method to private. The issue will be gone.

But when I defined the public method on both method as the below controller code, it will bring up the error.

Anyone help/advice if possible would be really appreciate

WEBLABController.cs

[Route("api/SearchLABResults")]
    [HttpPost]
    public async Task<IActionResult> SearchLABResults([FromBody] SP_GET_LABResult_Overview.input data)
    {
        IActionResult response = Unauthorized();
        ......
        return response;
    }

AuthenticationController.cs

[Route("api/GenerateToken")]
    [HttpPost]
    public async Task<IActionResult> GenerateToken([FromBody] AuthenticationModel.input data)
    {
        IActionResult response = Unauthorized();
        ......
        return response;
    }
1
  • Check other methods to be certain there are no duplicates route. Swagger would not launch if it detects methods with the same route Commented Jul 18, 2021 at 6:44

1 Answer 1

2

If you scroll down the swagger view, You see that every model you are using is shown there. Swagger needs that those names be unique.

SP_GET_LABResult_Overview.input and AuthenticationModel.input are both generate input schema and that cause InvalidOperationException.

Try to change one of the input classes to something else or change their schema on the fly like this.

services.AddSwaggerGen(options =>
{
    options.CustomSchemaIds(type => type.ToString());
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.