diff --git a/CHANGELOG.md b/CHANGELOG.md index c39a37e..f1dcbcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,36 @@ Proteus Changelog. ## Unreleased ### No issue +**Incorrect File.sep() use - broken on Windows.** + + * On Windows: + * ``` + * GET /v1/openapi/* [*/*] [*/*] (OpenAPIService._) + * GET /v1/openapi/redoc [*/*] [text/html] (OpenAPIService._) + * GET /v1\openapi.yaml [*/*] [text/yaml] (OpenAPIService._) + * ``` + +[bea9fd3de5d1d4d](https://github.com/noboomu/proteus/commit/bea9fd3de5d1d4d) nich0s *2020-05-01 13:35:04* + +**Better error logs.** + + +[aad21cfa3e050d3](https://github.com/noboomu/proteus/commit/aad21cfa3e050d3) Joshua Bauer *2020-04-28 16:04:11* + +**Update README.md** + + +[e3fac1fd8f268ef](https://github.com/noboomu/proteus/commit/e3fac1fd8f268ef) JL Bauer *2020-04-02 02:11:17* + **Added multipart/form-data media type.** [544668fabf96683](https://github.com/noboomu/proteus/commit/544668fabf96683) Joshua Bauer *2020-03-30 23:14:29* + +## v0.4.5 +### No issue + **Set version to 4.5 for release** diff --git a/pom.xml b/pom.xml index 2d0402d..a60a778 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ 1.8 1.8 UTF-8 - 2.0.20.Final + 2.1.0.Final 2.9.8 28.1-jre 4.2.2 diff --git a/proteus-core/src/main/java/io/sinistral/proteus/modules/ApplicationModule.java b/proteus-core/src/main/java/io/sinistral/proteus/modules/ApplicationModule.java index 841cb02..e3b00bc 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/modules/ApplicationModule.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/modules/ApplicationModule.java @@ -47,15 +47,7 @@ public ApplicationModule(Config config) */ public void bindMappers() { - JacksonXmlModule xmlModule = new JacksonXmlModule(); - xmlModule.setDefaultUseWrapper(false); - - XmlMapper xmlMapper = new XmlMapper(xmlModule); - - xmlMapper.enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION); - - this.bind(XmlMapper.class).toInstance(xmlMapper); try { @@ -79,6 +71,28 @@ public void bindMappers() } + try { + + String className = config.getString("application.xmlModule"); + + log.info("Installing XmlModule " + className); + + Class clazz = (Class) Class.forName(className); + + AbstractModule module = clazz.newInstance(); + + install(module); + + } catch (Exception e) { + + this.binder().addError(e); + + log.error(e.getMessage(), e); + + install(new XmlModule()); + + } + this.requestStaticInjection(Extractors.class); this.requestStaticInjection(ServerResponse.class); this.requestStaticInjection(JsonViewWrapper.class); diff --git a/proteus-core/src/main/java/io/sinistral/proteus/modules/XmlModule.java b/proteus-core/src/main/java/io/sinistral/proteus/modules/XmlModule.java new file mode 100644 index 0000000..8381607 --- /dev/null +++ b/proteus-core/src/main/java/io/sinistral/proteus/modules/XmlModule.java @@ -0,0 +1,47 @@ +package io.sinistral.proteus.modules; + +import com.ctc.wstx.api.WstxInputProperties; +import com.ctc.wstx.api.WstxOutputProperties; +import com.ctc.wstx.stax.WstxInputFactory; +import com.ctc.wstx.stax.WstxOutputFactory; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.dataformat.xml.XmlFactory; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; +import com.google.inject.AbstractModule; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; + +public class XmlModule extends AbstractModule { + + @Override + protected void configure() { + + XMLInputFactory inputFactory = new WstxInputFactory(); + inputFactory.setProperty(WstxInputProperties.P_MAX_ATTRIBUTE_SIZE, 32000); + + bind(XMLInputFactory.class).toInstance(inputFactory); + + XMLOutputFactory outputFactory = new WstxOutputFactory(); + outputFactory.setProperty(WstxOutputProperties.P_OUTPUT_CDATA_AS_TEXT, true); + + bind(XMLOutputFactory.class).toInstance(outputFactory); + + XmlFactory xmlFactory = new XmlFactory(inputFactory, outputFactory); + + XmlMapper xmlMapper = new XmlMapper(xmlFactory); + xmlMapper.registerModule(new JavaTimeModule()) + .registerModule(new ParameterNamesModule()) + .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + + xmlMapper.enable(ToXmlGenerator.Feature.WRITE_XML_DECLARATION); + + bind(XmlMapper.class).toInstance(xmlMapper); + + } +} diff --git a/proteus-core/src/main/resources/reference.conf b/proteus-core/src/main/resources/reference.conf index a35c6b2..a0c0f73 100644 --- a/proteus-core/src/main/resources/reference.conf +++ b/proteus-core/src/main/resources/reference.conf @@ -23,6 +23,7 @@ application { defaultResponseListener = "io.sinistral.proteus.server.handlers.ServerDefaultResponseListener" jacksonModule = "io.sinistral.proteus.modules.JacksonModule" + xmlModule = "io.sinistral.proteus.modules.XmlModule" tmpdir = ${java.io.tmpdir}/${application.name}