Skip to content

Commit cf15bb6

Browse files
committed
Documentation
1 parent 6416e48 commit cf15bb6

File tree

4 files changed

+56
-22
lines changed

4 files changed

+56
-22
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This web service implements a **[Data Validation API](#API)** being specified as
1313
- [From sources](#from-sources)
1414
- [With Docker](#with-docker)
1515
- [Configuration](#configuration)
16+
- [Service settings](#service-settings)
1617
- [Profiles](#profiles)
1718
- [Checks](#checks)
1819
- [API](#api)
@@ -33,7 +34,7 @@ Requires basic development toolchain (`sudo apt install build-essential`) and Py
3334

3435
1. clone repository: `git clone https://github.com/gbv/validation-api-ws.git && cd validation-api-ws`
3536
2. run `make deps` to install dependencies
36-
3. optionally [Configure](#configuration] the instance with
37+
3. optionally [Configure](#configuration) the instance
3738
3. `make start`
3839

3940
### Via Docker
@@ -44,7 +45,7 @@ A Docker image is automatically build [and published](https://github.com/orgs/gb
4445
docker run --rm -p 7007:7007 ghcr.io/gbv/validation-api-ws:main
4546
~~~
4647

47-
A [configuration] directory or file must exist and be mounted:
48+
A [configuration](#configuration) directory or file must exist and be mounted:
4849

4950
~~~sh
5051
test -f data/config.json && docker run --rm -p 7007:7007 --volume config:/app/config ghcr.io/gbv/validation-api-ws:main
@@ -53,7 +54,7 @@ test -f config.json && docker run --rm -p 7007:7007 --volume ./config.json:/app/
5354

5455
## Configuration
5556

56-
The [default configuration](config.default.json) contains some base formats. To defined the application profiles to be checked against, create a configuration file in JSON format at `config.json` in the current directory or in the local subdirectory `config`. It is also possible to pass the location of config file or directory with argument `--config` at startup. The configuration file must contain field `profiles` with a list of [profile objects](#profiles) and it can contain additional service settings.
57+
The [default configuration](config.default.json) contains some base formats. To defined application profiles to be checked against, create a configuration file in JSON format at `config.json` in the current directory or in the local subdirectory `config`. It is also possible to pass the location of config file or directory with argument `--config` at startup. The configuration file must contain field `profiles` with a list of [profile objects](#profiles) and it can contain additional service settings.
5758

5859
### Service settings
5960

@@ -95,9 +96,11 @@ Validate data against an application profile and return a list of errors in [Dat
9596
- `url` to be downloaded from an URL (if the service is configured with `downloads` directory)
9697
- `file` to be read from a local file in the stage directory of the server (if the service is configured with `stage` directory)
9798

98-
Status code is always 200 if validation could be executed, no matter whether errors have been found or not.
99+
Status code is always 200 if validation could be executed, no matter whether errors have been found or not. For example validating the string `[1,2` at default profile `json` results in the following validation response. The error position (after the fourth character on line 1) is referenced with multiple dimensions. Dimension values are always strings.
99100

100-
For example validating the string `[1,2` at default profile `json` (`curl http://localhost:7007/json/validate -d '[1,2'`) results in the following validation response. The error position (after the fourth character on line 1) is referenced with multiple dimensions. Dimension values are always strings.
101+
~~~sh
102+
curl http://localhost:7007/json/validate -d '[1,2'
103+
~~~
101104

102105
~~~json
103106
[
@@ -138,10 +141,10 @@ test -f config.json && docker run --rm -p 7007:7007 --volume ./config.json:/app/
138141

139142
See also <https://github.com/gbv/validation-server> for a previous implementation in NodeJS. Both implementations may converge
140143

141-
This work is [funded by DFG (project "AQinDa")](https://gepris.dfg.de/gepris/projekt/521659096)
142-
143144
## License
144145

145146
MIT © 2025- Verbundzentrale des GBV (VZG)
146147

148+
This work has been [funded by DFG in project *AQinDa*](https://gepris.dfg.de/gepris/projekt/521659096)
149+
147150
[Data Validation Error Format]: https://gbv.github.io/validation-error-format/

config.default.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
"profiles": [
77
{
88
"id": "json",
9+
"url": "https://json.org/",
10+
"description": "Check data to be JSON",
911
"checks": ["json"]
1012
},
1113
{
1214
"id": "xml",
15+
"description": "Check data to be well-formed XML",
1316
"checks": ["xml"]
1417
}
1518
]

lib/validate/profiles-schema.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@
1313
"type": "string"
1414
},
1515
"description": {
16-
"description": "Short description(s) of the profile, indexed by language tag (e.g. 'en')",
17-
"type": "object",
18-
"propertyNames": {
19-
"pattern": "^[a-z]{2,}$"
20-
}
16+
"description": "Short description of the profile",
17+
"type": "string"
2118
},
2219
"url": {
2320
"description": "URL of a document about the profile",

templates/index.html

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,18 @@
99
margin: 20px;
1010
font-family: sans-serif;
1111
}
12-
ul {
13-
list-style-type: none;
14-
padding: 0 1em;
15-
}
16-
li {
17-
text-indent: -2.5em;
18-
padding-left: 2.5em;
19-
margin-bottom: 0.2em;
20-
}
2112
a {
2213
text-decoration: none;
2314
color: rgb(96, 143, 219);
2415
}
2516
a:hover, a:active {
2617
text-decoration: underline;
2718
}
19+
dt {
20+
font-weight: bold;
21+
}
2822
footer {
23+
padding-top: 1em;
2924
color: #999;
3025
}
3126
</style>
@@ -39,11 +34,47 @@ <h2>API Endpoints</h2>
3934
<dl>
4035
<dt><a href="profiles">GET profiles</a></dt>
4136
<dd>
37+
Return a list of supported application profiles
4238
<a href="https://github.com/gbv/validation-api-ws#get-profiles">help</a>
4339
</dd>
40+
<dt>GET {profile}/validate</dt>
41+
<dd>
42+
Validate data against an application profile
43+
<a href="https://github.com/gbv/validation-api-ws#get-profilevalidate">help</a>
44+
</dd>
45+
<dt>POST {profile}/validate</dt>
46+
<dd>
47+
Validate data against an application profile
48+
<a href="https://github.com/gbv/validation-api-ws#post-profilevalidate">help</a>
49+
</dd>
4450
</p>
51+
<h2>Profiles</h2>
52+
<ul id="profiles">
53+
</ul>
4554
<footer>
4655
powered by <a href="https://github.com/gbv/validation-api-ws">validation-service</a>
4756
</footer>
4857
</body>
49-
</html>
58+
</html>
59+
<script>
60+
fetch("profiles").then(res => res.json()).then(profiles => {
61+
const ul = document.getElementById("profiles")
62+
profiles.forEach(({ id, url, description }) => {
63+
const li = document.createElement('li')
64+
if (url) {
65+
const a = document.createElement('a')
66+
a.href = url
67+
a.textContent = id
68+
li.appendChild(a)
69+
} else {
70+
li.textContent = id
71+
}
72+
if (description) {
73+
const span = document.createElement('span')
74+
span.textContent = ": " + description
75+
li.appendChild(span)
76+
}
77+
ul.appendChild(li)
78+
})
79+
})
80+
</script>

0 commit comments

Comments
 (0)