Swashbuckle.WebApi
Swashbuckle.WebApi copied to clipboard
Nested classes introduce invalid $ref values
VERSION:
5.0.0-rc2
STEPS TO REPRODUCE:
Create a class within a class such as the following:
public class OuterClass {
public class InnerClass { }
}
Within the controller, have a method such as the following that accepts the inner class as a parameter:
public async Task<ActionResult> DoSomething(Guid id, string something, [FromBody]OuterClass.InnerClass) {
//Something
return Ok();
}
The swagger output (looking at the OpenApi 3.0.1 output) when pasted into https://editor.swagger.io/ will generally work great, but the above will show an error of "$ref values must be RFC3986-compliant percent-encoded URIs"
Specifically, the output in offending line will read:
$ref: '#/Api-v1-Controllers-Api-DoSomething+InnerClass
Notably, it's the '+' that's throwing the error - changing this to a '-' resolves it without issue.
EXPECTED RESULT:
I'd expect to see an RFC3986-compliant value in each generated $ref value, specifically one without a '+' in it.
ACTUAL RESULT:
$ref: '#/Api-v1-Controllers-Api-DoSomething+InnerClass
ADDITIONAL DETAILS
Nothing else comes to mind, but happy to answer any questions as you have them.
I'm seeing the + as well.
This is still happened as of version 6.2.3
Azure APIM is rejecting the generated open API due to this issue.