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

Do not consider abstract classes in configuration options #362

Merged
merged 4 commits into from
Feb 22, 2022

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 v1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants