org.eclipse.microprofile.openapi.models.info.Info Java Examples

The following examples show how to use org.eclipse.microprofile.openapi.models.info.Info. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InfoReader.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
/**
 * Annotation to Info
 * 
 * @param annotationValue the {@literal @}Info annotation
 * @return Info model
 */
public static Info readInfo(final AnnotationValue annotationValue) {
    if (annotationValue == null) {
        return null;
    }
    IoLogging.log.annotation("@Info");
    AnnotationInstance nested = annotationValue.asNested();

    Info info = new InfoImpl();
    info.setTitle(JandexUtil.stringValue(nested, InfoConstant.PROP_TITLE));
    info.setDescription(JandexUtil.stringValue(nested, InfoConstant.PROP_DESCRIPTION));
    info.setTermsOfService(JandexUtil.stringValue(nested, InfoConstant.PROP_TERMS_OF_SERVICE));
    info.setContact(ContactReader.readContact(nested.value(InfoConstant.PROP_CONTACT)));
    info.setLicense(LicenseReader.readLicense(nested.value(InfoConstant.PROP_LICENSE)));
    info.setVersion(JandexUtil.stringValue(nested, InfoConstant.PROP_VERSION));
    return info;
}
 
Example #2
Source File: InfoReader.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
/**
 * Reads an {@link Info} OpenAPI node.
 * 
 * @param node the json node
 * @return Info model
 */
public static Info readInfo(final JsonNode node) {
    if (node == null) {
        return null;
    }
    IoLogging.log.singleJsonNode("Info");

    Info info = new InfoImpl();
    info.setTitle(JsonUtil.stringProperty(node, InfoConstant.PROP_TITLE));
    info.setDescription(JsonUtil.stringProperty(node, InfoConstant.PROP_DESCRIPTION));
    info.setTermsOfService(JsonUtil.stringProperty(node, InfoConstant.PROP_TERMS_OF_SERVICE));
    info.setContact(ContactReader.readContact(node.get(InfoConstant.PROP_CONTACT)));
    info.setLicense(LicenseReader.readLicense(node.get(InfoConstant.PROP_LICENSE)));
    info.setVersion(JsonUtil.stringProperty(node, InfoConstant.PROP_VERSION));
    ExtensionReader.readExtensions(node, info);
    return info;
}
 
Example #3
Source File: InfoWriter.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the {@link Info} model to the JSON tree.
 * 
 * @param parent the parent json node
 * @param model the Info model
 */
public static void writeInfo(ObjectNode parent, Info model) {
    if (model == null) {
        return;
    }
    ObjectNode node = parent.putObject(DefinitionConstant.PROP_INFO);

    JsonUtil.stringProperty(node, InfoConstant.PROP_TITLE, model.getTitle());
    JsonUtil.stringProperty(node, InfoConstant.PROP_DESCRIPTION, model.getDescription());
    JsonUtil.stringProperty(node, InfoConstant.PROP_TERMS_OF_SERVICE, model.getTermsOfService());
    ContactWriter.writeContact(node, model.getContact());
    LicenseWriter.writeLicense(node, model.getLicense());
    JsonUtil.stringProperty(node, InfoConstant.PROP_VERSION, model.getVersion());
    ExtensionWriter.writeExtensions(node, model);
}
 
Example #4
Source File: OASFactoryResolverImplTest.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * Test method for
 * {@link OASFactoryResolverImpl#createObject(java.lang.Class)}.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testCreateObject_All() {
    Class modelClasses[] = { APIResponse.class, APIResponses.class, Callback.class, Components.class,
            Contact.class, Content.class, Discriminator.class, Encoding.class, Example.class,
            ExternalDocumentation.class, Header.class, Info.class, License.class, Link.class, MediaType.class,
            OAuthFlow.class, OAuthFlows.class, OpenAPI.class, Operation.class, Parameter.class, PathItem.class,
            Paths.class, RequestBody.class, Schema.class, SecurityRequirement.class,
            SecurityScheme.class, Server.class, ServerVariable.class, Tag.class, XML.class };
    for (Class modelClass : modelClasses) {
        Constructible object = OASFactory.createObject(modelClass);
        Assert.assertNotNull(object);
    }
}
 
Example #5
Source File: OpenAPIImpl.java    From smallrye-open-api with Apache License 2.0 4 votes vote down vote up
/**
 * @see org.eclipse.microprofile.openapi.models.OpenAPI#getInfo()
 */
@Override
public Info getInfo() {
    return this.info;
}
 
Example #6
Source File: OpenAPIImpl.java    From smallrye-open-api with Apache License 2.0 4 votes vote down vote up
/**
 * @see org.eclipse.microprofile.openapi.models.OpenAPI#setInfo(org.eclipse.microprofile.openapi.models.info.Info)
 */
@Override
public void setInfo(Info info) {
    this.info = info;
}
 
Example #7
Source File: ModelConstructionTest.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@Test
public void infoTest() {
    processConstructible(Info.class);
}
 
Example #8
Source File: OpenAPI.java    From microprofile-open-api with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the info property from an OpenAPI instance.
 *
 * @return metadata about the API
 **/
Info getInfo();
 
Example #9
Source File: OpenAPI.java    From microprofile-open-api with Apache License 2.0 2 votes vote down vote up
/**
 * Sets this OpenAPI instance's info property to the given object.
 *
 * @param info metadata about the API
 */
void setInfo(Info info);
 
Example #10
Source File: OASFactory.java    From microprofile-open-api with Apache License 2.0 2 votes vote down vote up
/**
 * This method creates a new {@link org.eclipse.microprofile.openapi.models.info.Info} instance.
 *
 * @return a new Info instance
 */
public static Info createInfo() {
    return createObject(Info.class);
}