You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: enable test package access from Maven plugin + documentation (#389)
* chore: add documentation for Maven plugin YAML support
* chore(test): include ObjectMapper change in module used by Maven plugin
* feat: support custom module loaded from test classpath
* chore(docs): describe loading Maven plugin module from test classes
Copy file name to clipboardExpand all lines: CHANGELOG.md
+11
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
7
7
## [Unreleased]
8
8
### `jsonschema-generator`
9
+
#### Added
10
+
- offer `SchemaGeneratorConfigBuilder.withObjectMapper()`; mainly for use in custom modules in combination with the Maven plugin, where the constructor parameter cannot be used instead
11
+
9
12
#### Changed
10
13
- consider JavaBeans API specification in getter naming convention for field names with the second character being uppercase (e.g., a field `xIndex` has the getter `getxIndex()` according to the specification)
11
14
- allow for field names starting with `is` to have getter of the same name (e.g., a field `isBool` may have the getter `isBool()`)
15
+
- the default `ObjectMapper` instance now includes the enabled `SerializationFeature.INDENT_OUTPUT`
12
16
13
17
### `jsonschema-module-jackson`
14
18
#### Added
@@ -23,6 +27,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
27
#### Fixed
24
28
- avoid rounding error when taking over the value from `@Schema(multipleOf)`
25
29
30
+
### `jsonschema-naven-plugin`
31
+
### Added
32
+
- support custom configuration `Module` being loaded from test classpath elements
33
+
34
+
### Changed
35
+
- a generated schema is now serialized through the configuration's `ObjectMapper` instance (e.g., granting control over pretty printing or even generating YAML instead of JSON files)
Copy file name to clipboardExpand all lines: jsonschema-maven-plugin/src/main/java/com/github/victools/jsonschema/plugin/maven/SchemaGeneratorMojo.java
Copy file name to clipboardExpand all lines: slate-docs/source/includes/_maven-plugin.md
+44-1
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,8 @@ The considered `<classpath>` may be further specified as one of four values:
34
34
-`WITH_COMPILE_DEPENDENCIES` : `PROJECT_ONLY` and compile dependencies
35
35
-`WITH_RUNTIME_DEPENDENCIES` : `PROJECT_ONLY` and runtime dependencies (default, if unspecified)
36
36
-`WITH_ALL_DEPENDENCIES` : all of the above
37
-
37
+
-`WITH_ALL_DEPENDENCIES_AND_TESTS` : all of the above, with the addition of the current project's test files
38
+
Note that this requires a different `<phase>` (e.g., `test-compile`) being specified on the `<execution>`.
38
39
----
39
40
40
41
By default, the plugin aborts if the glob pattern does not match any class. If this is not desired, the `<failIfNoClassesMatch>` property can be set to `false`.
@@ -122,3 +123,45 @@ Through the `<modules>` tag you can include the standard modules – potentially
122
123
You can also group any kind of configurations into a Module of your own and include it via its full class name.
123
124
Make sure your custom module is on the classpath (considering the project itself as well as all compile and runtime dependencies) and has a default constructor.
124
125
It is not possible to configure options for custom modules.
One possibility within such a custom Module (as mentioned above) is to configure the format of the generated schema files.
145
+
The file contents are being produced by the schema generator's associated `ObjectMapper`.
146
+
That default `ObjectMapper` can be replaced, e.g., to opt-out of the default pretty-printing or changing the file format to YAML.
147
+
The given example requires the inclusion of the extra `com.fasterxml.jackson.dataformat:jackson-dataformat-yaml` dependency.
148
+
149
+
### Loading custom Module from test classes
150
+
151
+
```xml
152
+
<executions>
153
+
<execution>
154
+
<phase>test-compile</phase>
155
+
<goals>
156
+
<goal>generate</goal>
157
+
</goals>
158
+
</execution>
159
+
</executions>
160
+
```
161
+
162
+
When you're using a custom Module (as mentioned above) for additional configuration options, but don't want to include it among your application code,
163
+
you can either package it as separate artifact and include that as dependency of the plugin (not going into further detail here)
164
+
or the custom Module class can be included in your test packages.
165
+
When you do the latter, the Maven plugin will by default not be able to load that class, since it won't be compiled yet in the Maven phase during which the schema generation is being executed.
166
+
The Maven `compile` phase is when the schema generation gets triggered by default.
167
+
If you want the test classes (including the custom Module) to be available, a later phase (most likely: `test-compile`) needs to be specified.
0 commit comments