use of org.geotoolkit.xsd.xml.v2001.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);
}
use of org.geotoolkit.xsd.xml.v2001.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;
}
use of org.geotoolkit.xsd.xml.v2001.Schema in project geotoolkit by Geomatys.
the class JAXBFeatureTypeReader method listFeatureTypes.
private void listFeatureTypes(Schema schema, GenericNameIndex<FeatureType> result) throws MismatchedFeatureException, IllegalNameException {
// then we look for feature type and groups
for (OpenAttrs opAtts : schema.getSimpleTypeOrComplexTypeOrGroup()) {
if (opAtts instanceof TopLevelElement) {
final TopLevelElement element = (TopLevelElement) opAtts;
final QName typeName = element.getType();
if (typeName != null) {
final ComplexType type = xsdContext.findComplexType(typeName);
if (type == null && xsdContext.findSimpleType(typeName) == null) {
LOGGER.log(Level.WARNING, "Unable to find a the declaration of type {0} in schemas.", typeName.getLocalPart());
continue;
}
// if (xsdContext.isFeatureType(type)) {
final BuildStack stack = new BuildStack();
Object typeObj = getType(typeName.getNamespaceURI(), type, stack, true);
FeatureType ft = null;
if (typeObj instanceof FeatureAssociationRole) {
ft = ((FeatureAssociationRole) typeObj).getValueType();
} else if (typeObj instanceof FeatureType) {
ft = (FeatureType) typeObj;
}
if (ft != null) {
addIfMissing(result, ft);
// if the type name is not the same as the element name, make a subtype
if (!ft.getName().tip().toString().equals(element.getName())) {
final GenericName name = NamesExt.create(NamesExt.getNamespace(ft.getName()), element.getName());
final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
ftb.setName(name);
ftb.setSuperTypes(ft);
final FeatureType renamed = ftb.build();
addIfMissing(result, renamed);
}
}
// }
} else {
LOGGER.log(Level.WARNING, "null typeName for element : {0}", element.getName());
}
}
}
}
use of org.geotoolkit.xsd.xml.v2001.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);
}
use of org.geotoolkit.xsd.xml.v2001.Schema in project geotoolkit by Geomatys.
the class JAXBFeatureTypeWriter method fillSchemaWithFeatureType.
private void fillSchemaWithFeatureType(final FeatureType featureType, final Schema schema, boolean addTopElement, Set<String> alreadyWritten) {
if (Utils.GML_FEATURE_TYPES.contains(featureType.getName())) {
// this type is part of the standard GML types
return;
}
// write parent types
for (FeatureType parent : featureType.getSuperTypes()) {
fillSchemaWithFeatureType(parent, schema, false, alreadyWritten);
}
final String typeNamespace = NamesExt.getNamespace(featureType.getName());
final String elementName = featureType.getName().tip().toString();
final String typeName = elementName + "Type";
if (addTopElement) {
final TopLevelElement topElement;
if ("3.2.1".equals(gmlVersion)) {
topElement = new TopLevelElement(elementName, new QName(typeNamespace, typeName), ABSTRACT_FEATURE_NAME_321);
} else {
topElement = new TopLevelElement(elementName, new QName(typeNamespace, typeName), ABSTRACT_FEATURE_NAME_311);
}
schema.addElement(topElement);
}
boolean ar = alreadyWritten.add(typeName);
final ExplicitGroup sequence = new ExplicitGroup();
final List<Attribute> attributes = new ArrayList<>();
for (final PropertyType pdesc : featureType.getProperties(false)) {
if (AttributeConvention.contains(pdesc.getName())) {
// skip convention properties
continue;
}
writeProperty(pdesc, sequence, schema, attributes, alreadyWritten);
}
if (addTopElement && ar) {
final ComplexContent content = getComplexContent(sequence);
final TopLevelComplexType tlcType = new TopLevelComplexType(typeName, content);
tlcType.getAttributeOrAttributeGroup().addAll(attributes);
schema.addComplexType(1, tlcType);
}
}
Aggregations