You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems due to TypeExtensions.SchemaDefinitionName not using Swashbuckle's SchemaIdSelector.
For ValueResourceInput<BoostingConfigurationRequest>, SchemaDefinitionName returns BoostingConfigurationRequestValueResourceInput, while Swashbuckle names it ValueResourceInput[BoostingConfigurationRequest]
If I create a custom SchemaIdSelector to have Swashbuckle generate the id the same way as TypeExtensions.SchemaDefinitionName, it works.
// from RequestExample.SetRequestExampleForOperationif(swaggerOptions.SerializeAsV2){// Swagger v2 doesn't have a request example on the path// Fallback to setting it on the object in the "definitions"stringschemaDefinitionName=requestType.SchemaDefinitionName();if(schemaRepository.Schemas.ContainsKey(schemaDefinitionName)){//HERE: the actual schema name in the repository don't match the one from SchemaDefinitionName(), so the example is not addedvarschemaDefinition=schemaRepository.Schemas[schemaDefinitionName];if(schemaDefinition.Example==null){schemaDefinition.Example=firstOpenApiExample;}}}
The text was updated successfully, but these errors were encountered:
This is the sort of edge case I have trouble supporting. You're using v2 which is not common, and generics examples which is also uncommon. I have a test case in my test project which works fine - I just tested it with v2:
But it sounds like you have a workaround, with "a custom SchemaIdSelector". How do you do that?
Swashbuckle.AspNetCore.Filter 7.0.2
When adding an example with an IExamplesProvider for a generic type, the example does no appear in the generated Swagger v2.
It seems due to TypeExtensions.SchemaDefinitionName not using Swashbuckle's SchemaIdSelector.
For
ValueResourceInput<BoostingConfigurationRequest>
, SchemaDefinitionName returns BoostingConfigurationRequestValueResourceInput, while Swashbuckle names it ValueResourceInput[BoostingConfigurationRequest]If I create a custom SchemaIdSelector to have Swashbuckle generate the id the same way as TypeExtensions.SchemaDefinitionName, it works.
The text was updated successfully, but these errors were encountered: