Skip to content

Commit

Permalink
stoicflame#32 Additional fix for xml namespace with prefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
mengjiann committed Aug 27, 2020
1 parent 688de47 commit cc837a3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ private void addNamespaceXml(IndentationPrinter ip, Property p) {
boolean renderAttribute = AccessorProperty.isAttribute(p);
boolean renderNamespace = namespace != null && !namespace.isEmpty();

String namespacePrefix = null;
if (renderNamespace && this.namespacePrefixMap != null && !this.namespacePrefixMap.isEmpty()) {
namespacePrefix = getNonNullAndNonEmpty(this.namespacePrefixMap.get(namespace));
}

if (!wrappedName.isPresent() && !renderAttribute && !renderNamespace) {
return;
}
Expand All @@ -339,6 +344,10 @@ private void addNamespaceXml(IndentationPrinter ip, Property p) {
if (renderNamespace) {
ip.add("namespace: ", namespace);
}
if (namespacePrefix != null && !namespacePrefix.isEmpty()) {
ip.add("prefix: ", namespacePrefix);
}

ip.prevLevel();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import javax.xml.bind.annotation.*;

@XmlType(name = "dataXmlDTO", namespace = "http://www.jyskebank.dk/enunciate/openapi/version/1")
@XmlRootElement(name="dataXmlDTO", namespace = "http://www.jyskebank.dk/enunciate/openapi/version/1")
@XmlRootElement(name = "dataXmlDTO", namespace = "http://www.jyskebank.dk/enunciate/openapi/version/1")
@XmlAccessorType(XmlAccessType.FIELD)
public class DataXmlDTO {
@XmlElement(name="aString")
private String aString;

@XmlElement
private DataXmlEnum anEnum;
@XmlElement(name = "aString")
private String aString;

@XmlElement
private DataXmlEnum anEnum;

@XmlElement(name = "dataValue", namespace = "http://www.jyskebank.dk/enunciate/openapi/version/2")
private DataXmlDTODataValue dataValue;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package dk.jyskebank.tools.enunciate.modules.openapi.confignamespacewithprefix;

import javax.xml.bind.annotation.*;

@XmlType(name = "dataXmlDTODataValue", namespace = "http://www.jyskebank.dk/enunciate/openapi/version/2")
@XmlAccessorType(XmlAccessType.FIELD)
public class DataXmlDTODataValue {

@XmlElement(name = "customString")
private String customString;

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<namespaces>
<namespace uri="http://www.jyskebank.dk/enunciate/openapi/version/1" id="prefix-a"/>
<namespace uri="http://www.jyskebank.dk/enunciate/openapi/version/2" id="prefix-b"/>
</namespaces>

<modules disabledByDefault="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,24 @@ components:
type: string
"anEnum":
$ref: "#/components/schemas/xml_ns0_dataXmlEnum"
"dataValue":
xml:
namespace: http://www.jyskebank.dk/enunciate/openapi/version/2
prefix: prefix-b
$ref: "#/components/schemas/xml_prefix-b_dataXmlDTODataValue"
xml:
name: dataXmlDTO
namespace: http://www.jyskebank.dk/enunciate/openapi/version/1
prefix: prefix-a
"xml_prefix-b_dataXmlDTODataValue":
title: "dataXmlDTODataValue"
allOf:
- type: string
format: binary
- type: object
properties:
"customString":
type: string
xml:
namespace: http://www.jyskebank.dk/enunciate/openapi/version/2
prefix: prefix-b

0 comments on commit cc837a3

Please sign in to comment.