Search in sources :

Example 1 with Schema

use of com.google.cloud.datacatalog.v1beta1.Schema in project policies-ui-backend by RedHatInsights.

the class OapiTest method validateOpenApi.

@Test
void validateOpenApi() throws Exception {
    OpenApi3 model = new OpenApi3Parser().parse(url, true);
    System.out.printf("OpenAPI Model at %s\n", url);
    if (!model.isValid()) {
        for (ValidationResults.ValidationItem item : model.getValidationItems()) {
            System.err.println(item);
        }
        fail("OpenAPI spec is not valid");
    }
    // 
    // Now that basic validation is done, we can add some of our own
    // 
    Map<String, Path> paths = model.getPaths();
    Map<String, Schema> schemas = model.getSchemas();
    // The base path filler. See also OASModifier.mangleName
    assertTrue(paths.containsKey("/"));
    // User config is private, so don't show it
    assertFalse(paths.containsKey("/user-config"));
    assertFalse(schemas.containsKey("SettingsValues"));
    // Check that openapi does not (again) collapse parameters
    assertEquals(9, paths.get("/policies").getOperation("get").getParameters().size());
    // Check that all properties are present ( https://github.com/smallrye/smallrye-open-api/issues/437 )
    Map<String, Schema> policyProperties = schemas.get("Policy").getProperties();
    assertEquals(9, policyProperties.size());
    assertTrue(policyProperties.containsKey("ctime"));
    assertTrue(policyProperties.containsKey("mtime"));
    // Now that the OpenAPI file has been validated, save a copy to the filesystem
    // This file is going to be uploaded in a regular CI build to know the API state
    // for a given build.
    InputStream in = url.openStream();
    Files.copy(in, Paths.get(TARGET_OPENAPI), StandardCopyOption.REPLACE_EXISTING);
}
Also used : Path(com.reprezen.kaizen.oasparser.model3.Path) ValidationResults(com.reprezen.kaizen.oasparser.val.ValidationResults) InputStream(java.io.InputStream) Schema(com.reprezen.kaizen.oasparser.model3.Schema) OpenApi3Parser(com.reprezen.kaizen.oasparser.OpenApi3Parser) OpenApi3(com.reprezen.kaizen.oasparser.model3.OpenApi3) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 2 with Schema

use of com.google.cloud.datacatalog.v1beta1.Schema in project efm-integrasjonspunkt by felleslosninger.

the class P360Client method sendEduMelding.

@Override
public PutMessageResponseType sendEduMelding(PutMessageRequestType request) {
    JAXBElement<no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType> p360request = new PutMessageRequestMapper().mapFrom(request);
    final WebServiceTemplate template = templateFactory.createTemplate("no.difi.meldingsutveksling.noarkexchange.p360.schema", PutMessageMarker.markerFrom(new PutMessageRequestWrapper(request)));
    JAXBElement<no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageResponseType> response = (JAXBElement<no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageResponseType>) template.marshalSendAndReceive(settings.getEndpointUrl(), p360request, new SoapActionCallback(SOAP_ACTION));
    PutMessageResponseType theResponse = new PutMessageResponseType();
    ModelMapper modelMapper = new ModelMapper();
    modelMapper.map(response.getValue(), theResponse);
    setUnmappedValues(response, theResponse);
    if (!isValid(theResponse)) {
        theResponse = new PutMessageResponseType();
        final no.difi.meldingsutveksling.noarkexchange.schema.AppReceiptType appReceiptType = new no.difi.meldingsutveksling.noarkexchange.schema.AppReceiptType();
        theResponse.setResult(appReceiptType);
        appReceiptType.setType("OK");
    }
    return theResponse;
}
Also used : no.difi.meldingsutveksling.noarkexchange.p360.schema(no.difi.meldingsutveksling.noarkexchange.p360.schema) PutMessageResponseType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageResponseType) JAXBElement(javax.xml.bind.JAXBElement) PutMessageRequestMapper(no.difi.meldingsutveksling.noarkexchange.p360.PutMessageRequestMapper) WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate) ModelMapper(org.modelmapper.ModelMapper) PutMessageRequestType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType) SoapActionCallback(org.springframework.ws.soap.client.core.SoapActionCallback)

Example 3 with Schema

use of com.google.cloud.datacatalog.v1beta1.Schema in project geotoolkit by Geomatys.

the class JAXBFeatureTypeWriter method write.

/**
 * Write an XML representation of the specified featureType into the Writer.
 *
 * @param feature The featureType to marshall.
 */
public void write(FeatureType feature, Writer writer) throws JAXBException {
    final Schema schema = getSchemaFromFeatureType(feature);
    final Marshaller marshaller = POOL.acquireMarshaller();
    marshaller.marshal(schema, writer);
    POOL.recycle(marshaller);
}
Also used : Marshaller(javax.xml.bind.Marshaller) Schema(org.geotoolkit.xsd.xml.v2001.Schema)

Example 4 with Schema

use of com.google.cloud.datacatalog.v1beta1.Schema in project geotoolkit by Geomatys.

the class XSDSchemaContext method read.

public Map.Entry<Schema, String> read(final Object candidate) throws JAXBException {
    Entry<Schema, String> schemaEntry = readSchema(candidate);
    listAllSchemas(schemaEntry.getKey(), schemaEntry.getValue(), new ArrayList<>());
    final Schema schema = schemaEntry.getKey();
    targetNamespace = schema.getTargetNamespace();
    final String location = schemaEntry.getValue();
    // we build the base url to retrieve imported xsd;
    final String baseLocation;
    if (location == null) {
        baseLocation = null;
    } else if (location.lastIndexOf('/') != -1) {
        baseLocation = location.substring(0, location.lastIndexOf('/') + 1);
    } else {
        baseLocation = location;
    }
    return new AbstractMap.SimpleImmutableEntry<>(schema, baseLocation);
}
Also used : Schema(org.geotoolkit.xsd.xml.v2001.Schema)

Example 5 with Schema

use of com.google.cloud.datacatalog.v1beta1.Schema in project gapic-generator-java by googleapis.

the class AsyncCreateSchema method asyncCreateSchema.

public static void asyncCreateSchema() throws Exception {
    // It may require modifications to work in your environment.
    try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) {
        CreateSchemaRequest request = CreateSchemaRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setSchema(Schema.newBuilder().build()).setSchemaId("schemaId-697673060").build();
        ApiFuture<Schema> future = schemaServiceClient.createSchemaCallable().futureCall(request);
        // Do something.
        Schema response = future.get();
    }
}
Also used : CreateSchemaRequest(com.google.pubsub.v1.CreateSchemaRequest) Schema(com.google.pubsub.v1.Schema) SchemaServiceClient(com.google.cloud.pubsub.v1.SchemaServiceClient)

Aggregations

Test (org.junit.Test)57 Schema (com.google.pubsub.v1.Schema)38 Schema (org.molgenis.emx2.Schema)38 AbstractMessage (com.google.protobuf.AbstractMessage)16 ByteString (com.google.protobuf.ByteString)16 QName (javax.xml.namespace.QName)16 File (java.io.File)15 IOException (java.io.IOException)15 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)15 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)14 ProjectName (com.google.pubsub.v1.ProjectName)14 URL (java.net.URL)14 LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)14 StringWriter (java.io.StringWriter)13 Schema (org.oasisopen.odata.csdl.v4.Schema)13 Schema (com.reprezen.kaizen.oasparser.model3.Schema)11 ArrayList (java.util.ArrayList)10 JAXBElement (javax.xml.bind.JAXBElement)10 HashMap (java.util.HashMap)9 List (java.util.List)9