feat: Schema

This commit is contained in:
Piotr Dec 2024-07-15 23:33:57 +02:00
parent 3edf1cfb27
commit 2a3bfb3a5b
Signed by: stawros
GPG key ID: F89F27AD8F881A91
3 changed files with 51 additions and 1 deletions

19
pom.xml
View file

@ -30,6 +30,7 @@
<!-- dependencies -->
<!-- plugins -->
<jsonschema2pojo.version>1.2.1</jsonschema2pojo.version>
</properties>
<dependencies>
@ -66,6 +67,24 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<version>${jsonschema2pojo.version}</version>
<configuration>
<sourceDirectory>${basedir}/schema</sourceDirectory>
<targetPackage>eu.ztsh.lfr.model</targetPackage>
<useBigDecimals>true</useBigDecimals>
<includeAdditionalProperties>false</includeAdditionalProperties>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View file

@ -13,7 +13,13 @@ Write an application that, at the endpoint specified by you, returns the yearly
[example_file.csv](example_file.csv)
## Example response
## Response
### Schema
[response_schema](schema/response.json)
### Example
```json
[
{

25
schema/response.json Normal file
View file

@ -0,0 +1,25 @@
{
"$id": "https://ztsh.eu/lfr/response.json",
"$schema": "http://json-schema.org/draft/2020-12/schema",
"type": "array",
"def": {
"entry": {
"type": "object",
"properties": {
"year": {
"type": "string"
},
"averageTemperature": {
"type": "number"
}
},
"required": [
"year",
"averageTemperature"
]
}
},
"items": {
"$ref": "#/def/entry"
}
}