diff --git a/.editorconfig b/.editorconfig index 72a7d08..54a8570 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,5 +6,5 @@ indent_size = 4 insert_final_newline = true trim_trailing_whitespace = true -[*.yaml] +[{*.yaml,*.json}] indent_size = 2 diff --git a/pom.xml b/pom.xml index 5cbeab4..1ad6a08 100644 --- a/pom.xml +++ b/pom.xml @@ -29,6 +29,7 @@ + 1.2.1 @@ -85,6 +86,22 @@ org.springframework.boot spring-boot-maven-plugin + + org.jsonschema2pojo + jsonschema2pojo-maven-plugin + ${jsonschema2pojo.version} + + ${basedir}/src/main/resources/schema + eu.ztsh.wymiana.model + + + + + generate + + + + diff --git a/src/main/resources/schema/rates.json b/src/main/resources/schema/rates.json new file mode 100644 index 0000000..2ed42d0 --- /dev/null +++ b/src/main/resources/schema/rates.json @@ -0,0 +1,53 @@ +{ + "$id": "https://api.nbp.pl/c/rates.json", + "$schema": "http://json-schema.org/draft/2020-12/schema", + "type": "object", + "def": { + "rate": { + "type": "object", + "properties": { + "no": { + "type": "string" + }, + "effectiveDate": { + "type": "string" + }, + "bid": { + "type": "number" + }, + "ask": { + "type": "number" + } + }, + "required": [ + "no", + "effectiveDate", + "bid", + "ask" + ] + } + }, + "properties": { + "table": { + "type": "string" + }, + "currency": { + "type": "string" + }, + "code": { + "type": "string" + }, + "rates": { + "type": "array", + "items": { + "$ref": "#/def/rate" + } + } + }, + "required": [ + "table", + "currency", + "code", + "rates" + ] +}