Skip to content

Commit fe79a7c

Browse files
author
Eyar Zilberman
authoredDec 13, 2021
Merge branch 'yannh:master' into master
2 parents c7894ba + c1b3e93 commit fe79a7c

6 files changed

+7128
-19
lines changed
 

‎Readme.md

+2
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ $ ./scripts/openapi2jsonschema.py https://raw.githubusercontent.com/aws/amazon-s
204204
JSON schema written to trainingjob-sagemaker-v1.json
205205
```
206206

207+
Some CRD schemas do not have explicit validation for fields implicitly validated by the Kubernetes API like `apiVersion`, `kind`, and `metadata`, thus additional properties are allowed at the root of the JSON schema by default, if this is not desired the `DENY_ROOT_ADDITIONAL_PROPERTIES` environment variable can be set to any non-empty value.
208+
207209
### Usage as a Github Action
208210

209211
Kubeconform is publishes Docker Images to Github's new Container Registry, ghcr.io. These images
Binary file not shown.

‎scripts/acceptance.bats

+17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
setup() {
44
rm -f prometheus_v1.json
5+
rm -f prometheus-monitoring-v1.json
56
}
67

78
@test "Should generate expected prometheus resource" {
@@ -19,3 +20,19 @@ setup() {
1920
run diff prometheus_v1.json ./fixtures/prometheus_v1-expected.json
2021
[ "$status" -eq 0 ]
2122
}
23+
24+
@test "Should output filename in {kind}-{group}-{version} format" {
25+
FILENAME_FORMAT='{kind}-{group}-{version}' run ./openapi2jsonschema.py fixtures/prometheus-operator-0prometheusCustomResourceDefinition.yaml
26+
[ "$status" -eq 0 ]
27+
[ "$output" = "JSON schema written to prometheus-monitoring-v1.json" ]
28+
run diff prometheus-monitoring-v1.json ./fixtures/prometheus_v1-expected.json
29+
[ "$status" -eq 0 ]
30+
}
31+
32+
@test "Should set 'additionalProperties: false' at the root" {
33+
DENY_ROOT_ADDITIONAL_PROPERTIES='true' run ./openapi2jsonschema.py fixtures/prometheus-operator-0prometheusCustomResourceDefinition.yaml
34+
[ "$status" -eq 0 ]
35+
[ "$output" = "JSON schema written to prometheus_v1.json" ]
36+
run diff prometheus_v1.json ./fixtures/prometheus_v1-denyRootAdditionalProperties.json
37+
[ "$status" -eq 0 ]
38+
}

0 commit comments

Comments
 (0)
Please sign in to comment.