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

The following examples show how to use org.eclipse.microprofile.openapi.models.info.License. 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: LicenseReader.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * Reads an License annotation.
 * 
 * @param annotationValue the {@literal @}License annotation
 * @return License model
 */
public static License readLicense(final AnnotationValue annotationValue) {
    if (annotationValue == null) {
        return null;
    }
    IoLogging.log.singleAnnotation("@License");
    AnnotationInstance nested = annotationValue.asNested();
    License license = new LicenseImpl();
    license.setName(JandexUtil.stringValue(nested, LicenseConstant.PROP_NAME));
    license.setUrl(JandexUtil.stringValue(nested, LicenseConstant.PROP_URL));
    return license;
}
 
Example #2
Source File: LicenseReader.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * Reads an {@link License} OpenAPI node.
 * 
 * @param node the json node
 * @return License model
 */
public static License readLicense(final JsonNode node) {
    if (node == null) {
        return null;
    }
    IoLogging.log.singleJsonNode("License");
    License license = new LicenseImpl();
    license.setName(JsonUtil.stringProperty(node, LicenseConstant.PROP_NAME));
    license.setUrl(JsonUtil.stringProperty(node, LicenseConstant.PROP_URL));
    ExtensionReader.readExtensions(node, license);
    return license;
}
 
Example #3
Source File: LicenseWriter.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the {@link License} model to the JSON tree.
 * 
 * @param parent the parent json node
 * @param model the License model
 */
public static void writeLicense(ObjectNode parent, License model) {
    if (model == null) {
        return;
    }
    ObjectNode node = parent.putObject(InfoConstant.PROP_LICENSE);

    JsonUtil.stringProperty(node, LicenseConstant.PROP_NAME, model.getName());
    JsonUtil.stringProperty(node, LicenseConstant.PROP_URL, model.getUrl());
    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: 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)}.
 */
@Test
public void testCreateObject_License() {
    License license = OASFactory.createObject(License.class).name("Test License").url("urn:test-url");
    Assert.assertNotNull(license);
    Assert.assertEquals(LicenseImpl.class, license.getClass());
    Assert.assertEquals("Test License", license.getName());
    Assert.assertEquals("urn:test-url", license.getUrl());
}
 
Example #6
Source File: InfoImpl.java    From smallrye-open-api with Apache License 2.0 4 votes vote down vote up
/**
 * @see org.eclipse.microprofile.openapi.models.info.Info#getLicense()
 */
@Override
public License getLicense() {
    return this.license;
}
 
Example #7
Source File: InfoImpl.java    From smallrye-open-api with Apache License 2.0 4 votes vote down vote up
/**
 * @see org.eclipse.microprofile.openapi.models.info.Info#setLicense(org.eclipse.microprofile.openapi.models.info.License)
 */
@Override
public void setLicense(License license) {
    this.license = license;
}
 
Example #8
Source File: OASFactoryErrorTest.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@Override
public License addExtension(String name, Object value) {
    return null;
}
 
Example #9
Source File: ModelConstructionTest.java    From microprofile-open-api with Apache License 2.0 4 votes vote down vote up
@Test
public void licenseTest() {
    processConstructible(License.class);
}
 
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.License} instance.
 *
 * @return a new License instance
 */
public static License createLicense() {
    return createObject(License.class);
}