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

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