本文整理了Java中io.swagger.v3.oas.models.media.XML
类的一些代码示例,展示了XML
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XML
类的具体详情如下:
包路径:io.swagger.v3.oas.models.media.XML
类名称:XML
[英]XML
[中]XML
代码示例来源:origin: swagger-api/swagger-core
protected XML resolveXml(Annotated a, Annotation[] annotations, io.swagger.v3.oas.annotations.media.Schema schema) {
// if XmlRootElement annotation, construct an Xml object and attach it to the model
XmlRootElement rootAnnotation = null;
if (a != null) {
rootAnnotation = a.getAnnotation(XmlRootElement.class);
}
if (rootAnnotation == null) {
if (annotations != null) {
for (Annotation ann: annotations) {
if (ann instanceof XmlRootElement) {
rootAnnotation = (XmlRootElement)ann;
break;
}
}
}
}
if (rootAnnotation != null && !"".equals(rootAnnotation.name()) && !"##default".equals(rootAnnotation.name())) {
XML xml = new XML().name(rootAnnotation.name());
if (rootAnnotation.namespace() != null && !"".equals(rootAnnotation.namespace()) && !"##default".equals(rootAnnotation.namespace())) {
xml.namespace(rootAnnotation.namespace());
}
return xml;
}
return null;
}
代码示例来源:origin: swagger-api/swagger-core
assertEquals(rootXml.getName(), "rootName");
final XML xml = property.getXml();
assertNotNull(xml);
assertNull(xml.getName());
assertTrue(xml.getAttribute());
assertNull(xml.getWrapped());
} else if ("name".equals(name)) {
final XML xml = property.getXml();
assertNotNull(xml);
assertEquals(xml.getName(), "renamed");
assertNull(xml.getAttribute());
assertNull(xml.getWrapped());
} else if (Arrays.asList("list", "forcedElement").contains(name)) {
assertNull(property.getXml());
final XML xml = property.getXml();
assertNotNull(xml);
assertEquals(xml.getName(), "wrappedListItems");
assertNull(xml.getAttribute());
assertTrue(xml.getWrapped());
} else {
fail(String.format("Unexpected property: %s", name));
代码示例来源:origin: swagger-api/swagger-core
/**
* Puts definitions for XML attribute.
*
* @param attribute XmlAttribute
* @param property property instance to be updated
*/
private static void applyAttribute(XmlAttribute attribute, Schema property) {
if (attribute != null) {
final XML xml = getXml(property);
xml.setAttribute(true);
setName(attribute.namespace(), attribute.name(), property);
}
}
代码示例来源:origin: swagger-api/swagger-core
/**
* Puts definitions for XML wrapper.
*
* @param wrapper XmlElementWrapper
* @param property property instance to be updated
*/
private static void applyElement(XmlElementWrapper wrapper, Schema property) {
if (wrapper != null) {
final XML xml = getXml(property);
xml.setWrapped(true);
// No need to set the xml name if the name provided by xmlelementwrapper annotation is ##default or equal to the property name | https://github.com/swagger-api/swagger-core/pull/2050
if (!"##default".equals(wrapper.name()) && !wrapper.name().isEmpty() && !wrapper.name().equals(property.getName())) {
xml.setName(wrapper.name());
}
}
}
代码示例来源:origin: swagger-api/swagger-core
@Test(description = "it should process an XML model attribute")
public void processXMLModelAttribute() {
final Map<String, Schema> schemas = ModelConverters.getInstance().readAll(Monster.class);
final Schema model = schemas.get("Monster");
assertNotNull(model);
assertTrue(model instanceof Schema);
XML xml = model.getXml();
assertNotNull(xml);
assertEquals(xml.getName(), "monster");
final Schema property = (Schema) model.getProperties().get("children");
assertNotNull(property);
xml = property.getXml();
assertTrue(xml.getWrapped());
assertNull(xml.getName());
}
代码示例来源:origin: io.swagger.parser.v3/swagger-parser-v3
return null;
XML xml = new XML();
xml.setName(value);
xml.setNamespace(value);
xml.setPrefix(value);
xml.setAttribute(attribute);
xml.setWrapped(wrapped);
xml.setExtensions(extensions);
代码示例来源:origin: io.swagger/swagger-codegen-generators
if (propertySchema.getXml().getAttribute() != null) {
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_XML_ATTRIBUTE_EXT_NAME, propertySchema.getXml().getAttribute());
codegenProperty.xmlPrefix = propertySchema.getXml().getPrefix();
codegenProperty.xmlName = propertySchema.getXml().getName();
codegenProperty.xmlNamespace = propertySchema.getXml().getNamespace();
if (propertySchema.getXml() != null) {
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_XML_WRAPPED_EXT_NAME,
propertySchema.getXml().getWrapped() == null ? false : propertySchema.getXml().getWrapped());
codegenProperty.xmlPrefix= propertySchema.getXml().getPrefix();
codegenProperty.xmlNamespace = propertySchema.getXml().getNamespace();
codegenProperty.xmlName = propertySchema.getXml().getName();
代码示例来源:origin: io.swagger.codegen.v3/swagger-codegen-generators
codegenModel.xmlPrefix = schema.getXml().getPrefix();
codegenModel.xmlNamespace = schema.getXml().getNamespace();
codegenModel.xmlName = schema.getXml().getName();
.getPrefix();
codegenModel.xmlNamespace = innerModel.getXml()
.getNamespace();
codegenModel.xmlName = innerModel.getXml()
.getName();
代码示例来源:origin: swagger-api/swagger-core
XmlElement xmlElement = (XmlElement) annotation;
if (xmlElement != null && xmlElement.name() != null && !"".equals(xmlElement.name()) && !"##default".equals(xmlElement.name())) {
XML xml = items.getXml() != null ? items.getXml() : new XML();
xml.setName(xmlElement.name());
items.setXml(xml);
代码示例来源:origin: swagger-api/swagger-core
@Override
public Optional<Schema> filterSchema(Schema schema, Map<String, List<String>> params, Map<String, String> cookies, Map<String, List<String>> headers) {
if (schema == null || StringUtils.isBlank(schema.getXml().getName())) {
return Optional.of(schema);
}
if (schema.getXml().getName().equals(MODEL)) {
return Optional.empty();
}
return Optional.of(schema);
}
}
代码示例来源:origin: org.openapitools/openapi-generator
XML xml = schema.getXml();
if (xml != null) {
if (xml.getName() != null) {
name = xml.getName();
for (String pName : properties.keySet()) {
Schema property = properties.get(pName);
if (property != null && property.getXml() != null && property.getXml().getAttribute() != null && property.getXml().getAttribute()) {
attributes.put(pName, property);
} else {
代码示例来源:origin: swagger-api/swagger-core
private static XML getXml(Schema property) {
final XML existing = property.getXml();
if (existing != null) {
return existing;
}
final XML created = new XML();
property.setXml(created);
return created;
}
代码示例来源:origin: org.openapitools/openapi-generator
private boolean paramHasXmlNamespace(CodegenParameter param, Map<String, Schema> definitions) {
Object refName = param.vendorExtensions.get("refName");
if ((refName != null) && (refName instanceof String)) {
String name = (String) refName;
Schema model = definitions.get(ModelUtils.getSimpleRef(name));
if (model != null) {
XML xml = model.getXml();
if ((xml != null) && (xml.getNamespace() != null)) {
return true;
}
}
}
return false;
}
代码示例来源:origin: org.openapitools/openapi-generator
Schema inner = as.getItems();
boolean wrapped = false;
if (schema.getXml() != null && schema.getXml().getWrapped() != null && schema.getXml().getWrapped()) {
wrapped = true;
代码示例来源:origin: org.openapitools.swagger.parser/swagger-parser-v3
return null;
XML xml = new XML();
xml.setName(value);
xml.setNamespace(value);
xml.setPrefix(value);
xml.setAttribute(attribute);
xml.setWrapped(wrapped);
xml.setExtensions(extensions);
代码示例来源:origin: io.swagger.codegen.v3/swagger-codegen-generators
if (propertySchema.getXml().getAttribute() != null) {
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_XML_ATTRIBUTE_EXT_NAME, propertySchema.getXml().getAttribute());
codegenProperty.xmlPrefix = propertySchema.getXml().getPrefix();
codegenProperty.xmlName = propertySchema.getXml().getName();
codegenProperty.xmlNamespace = propertySchema.getXml().getNamespace();
if (propertySchema.getXml() != null) {
codegenProperty.getVendorExtensions().put(CodegenConstants.IS_XML_WRAPPED_EXT_NAME,
propertySchema.getXml().getWrapped() == null ? false : propertySchema.getXml().getWrapped());
codegenProperty.xmlPrefix= propertySchema.getXml().getPrefix();
codegenProperty.xmlNamespace = propertySchema.getXml().getNamespace();
codegenProperty.xmlName = propertySchema.getXml().getName();
代码示例来源:origin: io.swagger/swagger-codegen-generators
codegenModel.xmlPrefix = schema.getXml().getPrefix();
codegenModel.xmlNamespace = schema.getXml().getNamespace();
codegenModel.xmlName = schema.getXml().getName();
.getPrefix();
codegenModel.xmlNamespace = innerModel.getXml()
.getNamespace();
codegenModel.xmlName = innerModel.getXml()
.getName();
代码示例来源:origin: swagger-api/swagger-core
@Test
public void testSimple() throws Exception {
final ModelConverter mr = modelResolver();
ModelConverterContextImpl ctx = new ModelConverterContextImpl(mr);
final Schema model = mr.resolve(new AnnotatedType(XmlDecoratedBean.class), ctx, null);
final XML xml = model.getXml();
assertNotNull(xml);
assertEquals(xml.getName(), "xmlDecoratedBean");
// Cast it to an array property
final ArraySchema property = (ArraySchema) model.getProperties().get("elements");
assertNotNull(property);
final XML propertyXml = property.getXml();
assertNotNull(propertyXml);
assertNull(propertyXml.getName());
assertTrue(propertyXml.getWrapped());
// Get the xml for items for the array property
final XML itemsXml = property.getItems().getXml();
assertNotNull(itemsXml);
// Check the name of item name
assertEquals(itemsXml.getName(), "element");
assertNotNull(model.getProperties().get("elementC"));
}
代码示例来源:origin: io.swagger.core.v3/swagger-core
XmlElement xmlElement = (XmlElement) annotation;
if (xmlElement != null && xmlElement.name() != null && !"".equals(xmlElement.name()) && !"##default".equals(xmlElement.name())) {
XML xml = items.getXml() != null ? items.getXml() : new XML();
xml.setName(xmlElement.name());
items.setXml(xml);
代码示例来源:origin: swagger-api/swagger-core
@Test(description = "it should serialize a parameterized type per 606")
public void serializeParameterizedType() {
final Map<String, Schema> schemas = readAll(Employee.class);
final Schema employee = (Schema) schemas.get("employee");
final Map<String, Schema> props = employee.getProperties();
final Iterator<String> et = props.keySet().iterator();
final Schema id = props.get(et.next());
assertTrue(id instanceof IntegerSchema);
final Schema firstName = props.get(et.next());
assertTrue(firstName instanceof StringSchema);
final Schema lastName = props.get(et.next());
assertTrue(lastName instanceof StringSchema);
final Schema department = props.get(et.next());
assertNotNull(department.get$ref());
final Schema manager = props.get(et.next());
assertNotNull(manager.get$ref());
final Schema team = props.get(et.next());
assertTrue(team instanceof ArraySchema);
final ArraySchema ap = (ArraySchema) team;
assertTrue(ap.getUniqueItems());
assertNotNull(employee.getXml());
assertEquals(employee.getXml().getName(), "employee");
}
内容来源于网络,如有侵权,请联系作者删除!