Skip to content

Conversation

@mgaffigan
Copy link
Contributor

Adds application/mirthapi+json as a supported content-type for the admin API's that serialize or deserialize objects.

  • Avoids the round-trip through XML as currently performed by ObjectJSONSerializer/JsonMessageBodyReader
  • Matches the OpenAPI spec, allowing auto-generated clients in most languages
  • Probably more performant, but not really the point.

application/json keeps the historical behavior - this functionality is opt-in.

Closes #188

Signed-off-by: Mitch Gaffigan <mitch.gaffigan@comcast.net>
Signed-off-by: Mitch Gaffigan <mitch.gaffigan@comcast.net>
@mgaffigan mgaffigan force-pushed the feature/normal-json branch from 5fcca68 to 39c9523 Compare October 18, 2025 18:46
@mgaffigan
Copy link
Contributor Author

Here's a few examples of the implementation:

Login:

POST https://localhost:8443/api/users/_login HTTP/1.1
User-Agent: Fiddler
X-Requested-With: Foo
Host: localhost:8443
Content-Type: application/x-www-form-urlencoded
Accept: application/mirthapi+json
Content-Length: 29

username=admin&password=admin

HTTP/1.1 200 OK
Date: Sat, 18 Oct 2025 19:03:49 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: false
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Headers: Content-Type
Content-Security-Policy: frame-ancestors 'none'
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000; includeSubDomains
Set-Cookie: JSESSIONID=node05y5j2mlzbr1hslxmsncseev91.node0; Path=/api; Secure
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: application/mirthapi+json
Content-Length: 33

{"status":"SUCCESS","message":""}

Get Current User:

GET https://localhost:8443/api/users/current HTTP/1.1
User-Agent: Fiddler
X-Requested-With: Foo
Host: localhost:8443
Accept: application/mirthapi+json
Cookie: JSESSIONID=node05y5j2mlzbr1hslxmsncseev91.node0

HTTP/1.1 200 OK
Date: Sat, 18 Oct 2025 19:05:02 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: false
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Headers: Content-Type
Content-Security-Policy: frame-ancestors 'none'
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000; includeSubDomains
Content-Type: application/mirthapi+json
Content-Length: 107

{"id":1,"username":"admin","lastLogin":"2025-10-18T19:03:49.622+00:00","strikeCount":0,"userConsent":false}

Add user:

POST https://localhost:8443/api/users/ HTTP/1.1
User-Agent: Fiddler
X-Requested-With: Foo
Host: localhost:8443
Content-Type: application/mirthapi+json
Accept: application/mirthapi+json
Cookie: JSESSIONID=node05y5j2mlzbr1hslxmsncseev91.node0
Content-Length: 22

{"username":"example"}

HTTP/1.1 204 No Content
Date: Sat, 18 Oct 2025 19:06:07 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: false
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Headers: Content-Type
Content-Security-Policy: frame-ancestors 'none'
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000; includeSubDomains

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a custom JSON media type (application/mirthapi+json) to the Mirth admin API to enable direct Jackson JSON serialization/deserialization, avoiding the historical XML round-trip. This aligns the API with the OpenAPI specification and supports auto-generated clients.

Key Changes:

  • Introduces ApiContentTypes.APPLICATION_MIRTHAPI_JSON constant
  • Adds JacksonJsonObjectMapperConfig provider for Jackson configuration
  • Registers Jackson JSON providers in MirthWebServer
  • Updates all servlet interface annotations to support the new media type

Reviewed changes

Copilot reviewed 31 out of 34 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ApiContentTypes.java Defines the new application/mirthapi+json media type constant
JacksonJsonObjectMapperConfig.java Configures Jackson ObjectMapper with deserialization settings and date handling
MirthWebServer.java Registers Jackson JSON providers for the API
ServerLogServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
GlobalMapServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
DirectoryResourceServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
DataPrunerServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
DashboardConnectorStatusServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
WebServiceConnectorServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
TcpConnectorServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
SmtpConnectorServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
JmsConnectorServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
DatabaseConnectorServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
HttpConnectorServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
FileConnectorServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
DocumentConnectorServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
UserServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
UsageServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
SystemServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
MessageServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
ExtensionServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
EventServletInterface.java Adds new media type to @Consumes/@Produces/@ApiResponse/@produces annotations
EngineServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
DatabaseTaskServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
ConfigurationServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
CodeTemplateServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
ChannelStatusServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
ChannelStatisticsServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
ChannelServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
ChannelGroupServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
AlertServletInterface.java Adds new media type to @Consumes/@Produces/@apiresponse annotations
jackson-module-jaxb-annotations-2.14.3.jar Binary JAR dependency added
jackson-jaxrs-json-provider-2.14.3.jar Binary JAR dependency added

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

[BUG] OpenAPI definition does not match response

1 participant