use of org.eclipse.microprofile.openapi.models.examples.Example in project empoa by OpenAPITools.
the class OASMerge method merge.
public static void merge(Header from, Header into) {
if (into == null) {
throw new IllegalArgumentException("Header 'into' parameter can not be null");
}
if (from != null) {
String fromRef = from.getRef();
if (fromRef != null) {
into.setRef(fromRef);
}
String fromDescription = from.getDescription();
if (fromDescription != null) {
into.setDescription(fromDescription);
}
Boolean fromRequired = from.getRequired();
if (fromRequired != null) {
into.setRequired(fromRequired);
}
Boolean fromDeprecated = from.getDeprecated();
if (fromDeprecated != null) {
into.setDeprecated(fromDeprecated);
}
Boolean fromAllowEmptyValue = from.getAllowEmptyValue();
if (fromAllowEmptyValue != null) {
into.setAllowEmptyValue(fromAllowEmptyValue);
}
Header.Style fromStyle = from.getStyle();
if (fromStyle != null) {
into.setStyle(fromStyle);
}
Boolean fromExplode = from.getExplode();
if (fromExplode != null) {
into.setExplode(fromExplode);
}
Schema fromSchema = from.getSchema();
if (fromSchema != null) {
Schema intoSchema = into.getSchema();
if (intoSchema != null) {
merge(fromSchema, intoSchema);
} else {
into.setSchema(OASCopy.copy(fromSchema));
}
}
Map<String, Example> fromExamples = from.getExamples();
if (fromExamples != null) {
Map<String, Example> intoExamples = into.getExamples();
if (intoExamples != null) {
for (Entry<String, Example> entry : fromExamples.entrySet()) {
if (intoExamples.containsKey(entry.getKey())) {
merge(entry.getValue(), intoExamples.get(entry.getKey()));
} else {
into.addExample(entry.getKey(), OASCopy.copy(entry.getValue()));
}
}
} else {
for (Entry<String, Example> entry : fromExamples.entrySet()) {
into.addExample(entry.getKey(), OASCopy.copy(entry.getValue()));
}
}
}
Object fromExample = from.getExample();
if (fromExample != null) {
into.setExample(fromExample);
}
Content fromContent = from.getContent();
if (fromContent != null) {
Content intoContent = into.getContent();
if (intoContent != null) {
merge(fromContent, intoContent);
} else {
into.setContent(OASCopy.copy(fromContent));
}
}
Map<String, Object> extensions = from.getExtensions();
if (extensions != null) {
for (Entry<String, Object> entry : extensions.entrySet()) {
into.addExtension(entry.getKey(), entry.getValue());
}
}
}
}
use of org.eclipse.microprofile.openapi.models.examples.Example in project empoa by OpenAPITools.
the class OASMerge method merge.
public static void merge(MediaType from, MediaType into) {
if (into == null) {
throw new IllegalArgumentException("MediaType 'into' parameter can not be null");
}
if (from != null) {
Schema fromSchema = from.getSchema();
if (fromSchema != null) {
Schema intoSchema = into.getSchema();
if (intoSchema != null) {
merge(fromSchema, intoSchema);
} else {
into.setSchema(OASCopy.copy(fromSchema));
}
}
Map<String, Example> fromExamples = from.getExamples();
if (fromExamples != null) {
Map<String, Example> intoExamples = into.getExamples();
if (intoExamples != null) {
for (Entry<String, Example> entry : fromExamples.entrySet()) {
if (intoExamples.containsKey(entry.getKey())) {
merge(entry.getValue(), intoExamples.get(entry.getKey()));
} else {
into.addExample(entry.getKey(), OASCopy.copy(entry.getValue()));
}
}
} else {
for (Entry<String, Example> entry : fromExamples.entrySet()) {
into.addExample(entry.getKey(), OASCopy.copy(entry.getValue()));
}
}
}
Object fromExample = from.getExample();
if (fromExample != null) {
into.setExample(fromExample);
}
Map<String, Encoding> fromEncoding = from.getEncoding();
if (fromEncoding != null) {
Map<String, Encoding> intoEncoding = into.getEncoding();
if (intoEncoding != null) {
for (Entry<String, Encoding> entry : fromEncoding.entrySet()) {
if (intoEncoding.containsKey(entry.getKey())) {
merge(entry.getValue(), intoEncoding.get(entry.getKey()));
} else {
into.addEncoding(entry.getKey(), OASCopy.copy(entry.getValue()));
}
}
} else {
for (Entry<String, Encoding> entry : fromEncoding.entrySet()) {
into.addEncoding(entry.getKey(), OASCopy.copy(entry.getValue()));
}
}
}
Map<String, Object> extensions = from.getExtensions();
if (extensions != null) {
for (Entry<String, Object> entry : extensions.entrySet()) {
into.addExtension(entry.getKey(), entry.getValue());
}
}
}
}
use of org.eclipse.microprofile.openapi.models.examples.Example in project empoa by OpenAPITools.
the class OASCopy method copy.
public static Header copy(Header from) {
if (from == null) {
return null;
}
Header to = OASFactory.createHeader();
to.setRef(from.getRef());
to.setDescription(from.getDescription());
to.setRequired(from.getRequired());
to.setDeprecated(from.getDeprecated());
to.setAllowEmptyValue(from.getAllowEmptyValue());
to.setStyle(from.getStyle());
to.setExplode(from.getExplode());
to.setSchema(copy(from.getSchema()));
Map<String, Example> examples = from.getExamples();
if (examples != null) {
for (Entry<String, Example> entry : examples.entrySet()) {
to.addExample(entry.getKey(), copy(entry.getValue()));
}
}
to.setExample(from.getExample());
to.setContent(copy(from.getContent()));
Map<String, Object> extensions = from.getExtensions();
if (extensions != null) {
for (Entry<String, Object> entry : extensions.entrySet()) {
to.addExtension(entry.getKey(), entry.getValue());
}
}
return to;
}
use of org.eclipse.microprofile.openapi.models.examples.Example in project empoa by OpenAPITools.
the class AbstractElementSerializerTest method testExampleWithReferenceToJson.
@Test
public void testExampleWithReferenceToJson() throws Exception {
Example example = OASElement.createExample().ref("#/components/examples/SomeExample").description("Some description");
String json = convertToJson(example);
assertThatJson(json).isEqualTo("" + "{" + " \"$ref\": \"#/components/examples/SomeExample\"" + "}");
}
use of org.eclipse.microprofile.openapi.models.examples.Example in project empoa by OpenAPITools.
the class AbstractElementSerializerTest method testEmptyExampleToJson.
@Test
public void testEmptyExampleToJson() throws Exception {
Example example = OASFactory.createExample();
String json = convertToJson(example);
assertThatJson(json).isEqualTo("{}");
}
Aggregations