use of fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl in project Payara by payara.
the class ContentImpl method createInstance.
public static ContentImpl createInstance(AnnotationModel annotation, ApiContext context) {
ContentImpl from = new ContentImpl();
String typeName = annotation.getValue("mediaType", String.class);
if (typeName == null || typeName.isEmpty()) {
typeName = javax.ws.rs.core.MediaType.WILDCARD;
}
MediaType mediaType = new MediaTypeImpl();
from.addMediaType(typeName, mediaType);
extractAnnotations(annotation, context, "examples", "name", ExampleImpl::createInstance, mediaType::addExample);
mediaType.setExample(annotation.getValue("example", String.class));
AnnotationModel schemaAnnotation = annotation.getValue("schema", AnnotationModel.class);
if (schemaAnnotation != null) {
Boolean hidden = schemaAnnotation.getValue("hidden", Boolean.class);
if (hidden == null || !hidden) {
mediaType.setSchema(SchemaImpl.createInstance(schemaAnnotation, context));
}
}
extractAnnotations(annotation, context, "encoding", "name", EncodingImpl::createInstance, mediaType::addEncoding);
return from;
}
use of fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl in project Payara by payara.
the class HeaderImpl method merge.
public static void merge(Header from, Header to, boolean override, ApiContext context) {
if (from == null) {
return;
}
if (from.getRef() != null && !from.getRef().isEmpty()) {
applyReference(to, from.getRef());
return;
}
to.setDescription(mergeProperty(to.getDescription(), from.getDescription(), override));
to.setRequired(mergeProperty(to.getRequired(), from.getRequired(), override));
to.setDeprecated(mergeProperty(to.getDeprecated(), from.getDeprecated(), override));
to.setAllowEmptyValue(mergeProperty(to.getAllowEmptyValue(), from.getAllowEmptyValue(), override));
to.setStyle(Style.SIMPLE);
to.setExplode(mergeProperty(to.getExplode(), from.getExplode(), override));
if (from.getSchema() != null) {
if (to.getSchema() == null) {
to.setSchema(new SchemaImpl());
}
SchemaImpl.merge(from.getSchema(), to.getSchema(), override, context);
}
to.setExample(mergeProperty(to.getExample(), from.getExample(), override));
if (from.getExamples() != null) {
for (String exampleName : from.getExamples().keySet()) {
if (exampleName != null) {
Example example = new ExampleImpl();
ExampleImpl.merge(from.getExamples().get(exampleName), example, override);
to.addExample(exampleName, example);
}
}
}
if (from.getContent() != null) {
if (to.getContent() == null) {
to.setContent(new ContentImpl());
}
ContentImpl.merge((ContentImpl) from.getContent(), to.getContent(), override, context);
}
}
use of fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl in project Payara by payara.
the class HeaderImpl method createInstance.
public static Header createInstance(AnnotationModel annotation, ApiContext context) {
HeaderImpl from = new HeaderImpl();
String ref = annotation.getValue("ref", String.class);
if (ref != null && !ref.isEmpty()) {
from.setRef(ref);
}
from.setDescription(annotation.getValue("description", String.class));
from.setRequired(annotation.getValue("required", Boolean.class));
from.setDeprecated(annotation.getValue("deprecated", Boolean.class));
from.setAllowEmptyValue(annotation.getValue("allowEmptyValue", Boolean.class));
EnumModel styleEnum = annotation.getValue("style", EnumModel.class);
if (styleEnum != null) {
from.setStyle(Header.Style.valueOf(styleEnum.getValue()));
}
from.setExplode(annotation.getValue("explode", Boolean.class));
AnnotationModel schemaAnnotation = annotation.getValue("schema", AnnotationModel.class);
if (schemaAnnotation != null) {
Boolean hidden = schemaAnnotation.getValue("hidden", Boolean.class);
if (hidden == null || !hidden) {
from.setSchema(SchemaImpl.createInstance(schemaAnnotation, context));
}
}
extractAnnotations(annotation, context, "examples", "name", ExampleImpl::createInstance, from::addExample);
from.setExample(annotation.getValue("example", Object.class));
final List<ContentImpl> contents = createList();
extractAnnotations(annotation, context, "content", ContentImpl::createInstance, contents::add);
for (ContentImpl content : contents) {
content.getMediaTypes().forEach(from.content::addMediaType);
}
return from;
}
Aggregations