2

My XML request looks like this:

   <ns1: MyRequest ns1="http://example.com/api/2.0">:
        <reference>A request to my endpoint</reference>
   </ns1:MyRequest>

I believe it should be modeled in Swagger/OpenAPI 3 spec as follows:

MyRequest:
  type: object
  properties:
    reference:
      type: string
      xml:
        name: reference
  xml:
    prefix: ns1
    namespace: https://example.com/api/2.0

Is it possible to annotate my MyRequest.java class appropriately using JAXB or Swagger annotations to get the prefix and namespace entries in the generated OpenAPI spec?

I tried setting the namespace attribute on the @XmlRootElement as below, but the namespace is not appearing in the generated OpenAPI spec. Further, I can't use that the XmlRootElement annotation to specify the prefix.

@XmlRootElement(namespace = "https://example.com/api/2.0")
public class MyRequest{
  //omitted
}
Steve
  • 21
  • 2

0 Answers0