Skip to content

Adds OpenAPI oneOf for connector properties at runtime#235

Open
NicoPiel wants to merge 4 commits intoOpenIntegrationEngine:mainfrom
NicoPiel:feature/properties-annotations
Open

Adds OpenAPI oneOf for connector properties at runtime#235
NicoPiel wants to merge 4 commits intoOpenIntegrationEngine:mainfrom
NicoPiel:feature/properties-annotations

Conversation

@NicoPiel
Copy link
Collaborator

@NicoPiel NicoPiel commented Jan 3, 2026

Adds an OpenAPI/Swagger Schema annotation to the connector properties field to declare concrete property subclasses via oneOf. This enables correct polymorphic schema generation for connector properties, improving API documentation and client code generation.

Also imports the Schema annotation required for the new metadata.

Adds an OpenAPI/Swagger Schema annotation to the connector properties field to declare concrete property subclasses via oneOf. This enables correct polymorphic schema generation for connector properties, improving API documentation and client code generation.

Also imports the Schema annotation required for the new metadata.

Signed-off-by: Nico Piel <nico.piel@hotmail.de>
@NicoPiel
Copy link
Collaborator Author

NicoPiel commented Jan 3, 2026

Previously missing connectors in a generated index.d.ts like HttpReceiverProperties now show up.

Copy link
Contributor

@mgaffigan mgaffigan left a comment

Choose a reason for hiding this comment

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

I think the intent is good, but this creates a compile-time dependency loop:

graph TD;
    com.mirth.connect.connectors.file-->core.mirth.connect.model
    core.mirth.connect.model-->com.mirth.connect.connectors.file
Loading

core.mirth.connect.model should be happily ignorant of implementations. Any discovery of implementations would need to happen at runtime, but would be instance specific.

@NicoPiel
Copy link
Collaborator Author

NicoPiel commented Jan 3, 2026

I could implement an OpenAPI customizer to detect implementations at runtime.

Replaces a hardcoded list of connector property types with runtime discovery to generate the OpenAPI schema for connector properties.

Uses reflection to find concrete ConnectorProperties subclasses and ModelConverters to register their schemas, composing a ConnectorProperties oneOf schema in the OpenAPI components. This keeps API docs in sync with available property implementations and removes the need to manually maintain annotation lists. It also ignores interfaces and abstract classes and preserves a stable ordering for generated schemas.

Signed-off-by: Nico Piel <nico.piel@hotmail.de>

private SortedSet<Class<? extends ConnectorProperties>> findConnectorPropertiesSubtypes() {
Reflections reflections = new Reflections(new ConfigurationBuilder()
.forPackages("com.mirth.connect")
Copy link
Member

Choose a reason for hiding this comment

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

question: Is it possible to scan the entire classpath?

I don't think you can assume that 3rd-party connectors will use this package name (or the connectors in this repo if we eventually migrate them to other packages.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I'm pretty sure that's entirely possible. I included that line for testing purposes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed.

Copy link
Member

Choose a reason for hiding this comment

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

Can you remove this file from the PR? I think you did not mean for the remaining two changes to still be in place.

Removes an unused Swagger Schema import and tidies up extraneous blank lines in the Connector class. Cleans up imports/formatting to prepare for property annotation changes on the properties-annotations branch.

Signed-off-by: Nico Piel <nico.piel@hotmail.de>
Replace package-limited scanning with ClasspathHelper-provided URLs for the Reflections configuration to make discovery of ConnectorProperties subtypes more robust across classloaders and deployment layouts.

Signed-off-by: Nico Piel <nico.piel@hotmail.de>
@NicoPiel NicoPiel changed the title Adds OpenAPI oneOf for connector properties Adds OpenAPI oneOf for connector properties at runtime Jan 6, 2026
@NicoPiel NicoPiel self-assigned this Mar 13, 2026
@NicoPiel NicoPiel requested review from a team, gibson9583, jonbartels, kayyagari, kpalang, mgaffigan, ssrowe and tonygermano and removed request for a team March 13, 2026 20:29
Copy link
Contributor

@mgaffigan mgaffigan left a comment

Choose a reason for hiding this comment

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

Blocking issues:

  1. getSimpleName() is not unique. Deserialization in the current disgusting deserializer is based on full name.
  2. Is it proper to use ModelConverters.getInstance() directly? It seems odd to me to assume the process will contain exactly one mapping of types to OpenAPI schema. I would assume it is possible to have two differently configured model converters per process.

Non-blocking issues:
3. I do not like relying upon classpath scanning since it pushes us farther away from modern practices like DI and being compatible with AOT. ConnectorProperties subtypes should be exposed by the plugin registry itself.
4. I assume that there are more polymorphic types than just ConnectorProperties - this does not seem structured to accommodate those.

Future work:
5. This does not adjust the deserializer itself (leaving JSON unsupported/nonmatching to the schema, and likely continuing to support RCE vectors). Long term, we should be adding the JsonTypeInfo and dynamic equivalent of JsonSubTypes. ObjectMapper.registerSubtypes seems relevant. (see allowTypes for some nauseous code)

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.

3 participants