Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method not found: 'Microsoft.OpenApi. Models.OpenApiSchema Swashbuckle. AspNetCore.SwaggerGen. IschemaGenerator.GenerateSchema in version 6.4.0 #2465

Closed
shrutigithub opened this issue Jul 21, 2022 · 5 comments
Labels
stale Stale issues or pull requests

Comments

@shrutigithub
Copy link

After Upgrading to swagger version 6.4.0 , we are getting error:
Method not found: 'Microsoft.OpenApi. Models.OpenApiSchema Swashbuckle. AspNetCore.SwaggerGen. IschemaGenerator.GenerateSchema

Detailed Stack trace:
See inner exception ---> Swashbuckle. AspNetCore.SwaggerGen. SwaggerGeneratorException: Failed to generate schema for type - System.String. See inner exception ---> System. MissingMethodException: Method not found: 'Microsoft.OpenApi. Models.OpenApiSchema Swashbuckle. AspNetCore.SwaggerGen. IschemaGenerator.GenerateSchema (Sys tem. Type, Swashbuckle.AspNetCore.SwaggerGen. SchemaRepository, System.Reflection. MemberInfo, System.Reflection. ParameterInfo)'.
at Microsoft.Azure.Global.Services. Common. Service.OpenApi.SchemaFilters. SubTypeOfFilter.Apply(OpenApiSchema schema, SchemaFilterContext context)
at Swashbuckle. AspNetCore.SwaggerGen. SchemaGenerator.ApplyFilters (OpenApiSchema schema, Type type, SchemaRepository schemaRepository, MemberInfo memberInfo, Para meterInfo parameterInfo)
at Swashbuckle. AspNetCore.SwaggerGen. SchemaGenerator.GenerateSchemaForType (Type modelType, SchemaRepository schemaRepository)
at Swashbuckle. AspNetCore.SwaggerGen. SchemaGenerator.GenerateSchema (Type modelType, SchemaRepository schemaRepository, MemberInfo memberInfo, ParameterInfo param eterInfo, ApiParameter RouteInfo routeInfo)
at Swashbuckle. AspNetCore.SwaggerGen. SwaggerGenerator.GenerateSchema (Type type, SchemaRepository schemaRepository, PropertyInfo propertyInfo, ParameterInfo param eterInfo, ApiParameter RouteInfo routeInfo)
--- End of inner exception stack trace ---
at Swashbuckle. AspNetCore.SwaggerGen. SwaggerGenerator.GenerateSchema (Type type, SchemaRepository schemaRepository, PropertyInfo propertyInfo, ParameterInfo param eterInfo, ApiParameter RouteInfo routeInfo)
at Swashbuckle. AspNetCore.SwaggerGen. SwaggerGenerator.GenerateParameter(ApiParameterDescription apiParameter, SchemaRepository schemaRepository)

Also , we tried upgrading to 5.6.0, we get the issue:

Unhandled exception. System.MissingMethodException: Method not found: 'Boolean Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository.TryGetIdFor(System.Type, System.String ByRef)'.
at Microsoft.Azure.Global.Services.Common.Service.OpenApi.DocumentFilters.PolymorphismDocumentFilter.RegisterSubClasses(SchemaRepository schemaRegistry, ISchemaGenerator schemaGenerator, Type abstractType)
at Microsoft.Azure.Global.Services.Common.Service.OpenApi.DocumentFilters.PolymorphismDocumentFilter.Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath)
at Swashbuckle.AspNetCore.Cli.Program.<>c.

b__0_3(IDictionary2 namedArgs) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\Program.cs:line 72 at Swashbuckle.AspNetCore.Cli.CommandRunner.Run(IEnumerable1 args) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\CommandRunner.cs:line 68
at Swashbuckle.AspNetCore.Cli.CommandRunner.Run(IEnumerable`1 args) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\CommandRunner.cs:line 68
at Swashbuckle.AspNetCore.Cli.Program.Main(String[] args) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\Program.cs:line 111

@shrutigithub
Copy link
Author

@domaindrivendev Please suggest a workaround. We need to fix this as soon as possible. Unable to upgrade to any swagger version after 5.5

@shrutigithub
Copy link
Author

shrutigithub commented Jul 21, 2022

Steps to replicate the issue:

  1. Upgraded the swagger version in 2 files:
    1.1. dotnet-tools.json file inside .config folder of our project : {"version":1,"isRoot":true,"tools":{"swashbuckle.aspnetcore.cli":{"version":"6.2.3","commands":["swagger"]}}}
    1.2. Package.props file :
  2. ran commad :
    dotnet swagger tofile --output destination-folder/swagger.json --serializeasv2 dll-file 1.0

@Aiiida
Copy link

Aiiida commented Sep 13, 2022

This seems to work #2369 (comment)

Copy link
Contributor

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

@github-actions github-actions bot added the stale Stale issues or pull requests label Apr 20, 2024
@martincostello martincostello closed this as not planned Won't fix, can't repro, duplicate, stale Apr 20, 2024
@martincostello
Copy link
Collaborator

#2801 would guard against unintended breaking changes in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale issues or pull requests
Projects
None yet
Development

No branches or pull requests

3 participants