Skip to content

Conversation

@gsteenpa
Copy link
Contributor

We use an abstract base class to share some configuration options. The resolver is picking up that abstract class and thowing an error on the SingleOrDefault.

This is the exception stack:

Sequence contains more than one matching element

   at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException()
   at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Resolvers.OpenApiConfigurationResolver.Resolve(Assembly assembly)
   at Microsoft.Azure.WebJobs.Extensions.OpenApi.OpenApiHttpTriggerContext.get_OpenApiConfigurationOptions()
   at Microsoft.Azure.WebJobs.Extensions.OpenApi.OpenApiTriggerFunctionProvider.RenderSwaggerUI(HttpRequest req, ExecutionContext ctx, ILogger log)

@justinyoo
Copy link
Contributor

@gsteenpa Thanks for the PR! However, I wonder whether this really needs or not because there's no abstract class in the code implementing IOpenApiConfigurationOptions, anyway. Would you mind providing a use case for this?

@gsteenpa
Copy link
Contributor Author

@gsteenpa Thanks for the PR! However, I wonder whether this really needs or not because there's no abstract class in the code implementing IOpenApiConfigurationOptions, anyway. Would you mind providing a use case for this?

Hi - We have an abstract base in our usage of the library so that we can share some settings (like setting a standard copyright with a dynamic year, forcing a specific openapi spec version, and ensuring a standard api title/description) across various apis. Each api then inherits from that base class in its implementation (the "concrete" class) to set api specific information.

@justinyoo
Copy link
Contributor

Oh, I see. Then, it would make senses.

@justinyoo justinyoo added enhancement New feature or request v1.2.0 labels Feb 15, 2022
Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you please add test cases to validate your change?

@justinyoo justinyoo added this to the Release 202202 - v1.2.0 milestone Feb 20, 2022
Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! It LGTM

@justinyoo justinyoo merged commit dad34bc into Azure:main Feb 22, 2022
@gsteenpa gsteenpa deleted the fix/no-abstract branch February 22, 2022 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants