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

v15: Swagger sub types selectors #17072

Open
wants to merge 8 commits into
base: contrib
Choose a base branch
from

Conversation

mattbrailsford
Copy link
Contributor

@mattbrailsford mattbrailsford commented Sep 16, 2024

Description

This PR introduces a new ISubTypesSelector and ISubTypesHandler implementation to allow overriding how Swagger resolves subtypes of a type based on both the base type and the API document name.

This is required as the current default behaviour is to resolve all type implementations of the base type across all app domain assemblies. This poses a problem if you have (like we do in Umbraco Commerce) a shared base class used by multiple Swagger documents. In this scenario Swagger will throw an exception as it attempts to load the types from all endpoint definitions, not just the for the given API, casing duplicate schema to be generated.

With this PR in the same way ISchemaIdSelector and IOperationIdSelector allow developers to customise the default behaviour of Umbraco whilst generating Swagger Schemas, this new ISubTypesSelector lets you override the sub type resolution process.

In order to maintain backwards compatibility I have set the default ISchemaIdSelector to use the previous functionality if no explicit ISubTypesSelector is defined that can handle the supplied type.

@mattbrailsford mattbrailsford changed the title v15: Swagger sub type selectors v15: Swagger sub types selectors Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants