Skip to content

Commit

Permalink
fix: model types and required
Browse files Browse the repository at this point in the history
  • Loading branch information
vordimous committed Aug 30, 2024
1 parent bdf4e1d commit 50ac3b7
Show file tree
Hide file tree
Showing 21 changed files with 92 additions and 63 deletions.
4 changes: 2 additions & 2 deletions .check-schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ This project compares the JSON Schema from the Zilla to the [Reference](../src/r
In the repository root directory run:

```bash
docker run -e ZILLA_INCUBATOR_ENABLED=true ghcr.io/aklivity/zilla:latest start -v -Pzilla.engine.verbose.schema.plain > ./.check-schema/zilla-schema.json
docker run -e ZILLA_INCUBATOR_ENABLED=true ghcr.io/aklivity/zilla:latest start -v -Pzilla.engine.verbose.schema > ./src/.vuepress/public/assets/zilla-schema.json
docker run -it --rm -e ZILLA_INCUBATOR_ENABLED=true ghcr.io/aklivity/zilla:latest start -v -Pzilla.engine.verbose.schema.plain > ./.check-schema/zilla-schema.json
docker run -it --rm -e ZILLA_INCUBATOR_ENABLED=true ghcr.io/aklivity/zilla:latest start -v -Pzilla.engine.verbose.schema > ./src/.vuepress/public/assets/zilla-schema.json
```

Once the docker container has printed "started" it must be deleted for the command to complete.
Expand Down
20 changes: 10 additions & 10 deletions .check-schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ const main = async () => {
...(then.properties?.options?.properties || {}),
}
} : {}),
required: [...(props?.required || []), ...(then.required || [])],
anyOf: [...(then.anyOf || [])],
},
required: [...(props?.required || []), ...(then.required || [])],
}))
).flat(1);

Expand Down Expand Up @@ -218,10 +218,10 @@ const main = async () => {
}
}
} : {}),
required: [...(then.required || []), ...(required || [])],
oneOf,
anyOf: [...(then.anyOf || []), ...(anyOf || [])],
},
required: [...(then.required || []), ...(required || [])],
})));
} else {
sections.push({
Expand All @@ -240,8 +240,8 @@ const main = async () => {
}
}
} : {}),
required: [...(then.required || [])],
}
},
required: [...(then.required || [])],
});
}
})
Expand All @@ -255,9 +255,9 @@ const main = async () => {
props: {
...(exporterProps?.properties || {}),
...(then.properties || {}),
required: [...(exporterProps?.required || []), ...(then.required || [])],
anyOf: [...(then.anyOf || [])],
}
},
required: [...(exporterProps?.required || []), ...(then.required || [])],
}))
);
sections.push(
Expand All @@ -266,21 +266,21 @@ const main = async () => {
name: fi.properties.model.const,
props: {
...(then.properties || {}),
required: (then.required || []),
anyOf: (then.anyOf || []),
}
},
required: (then.required || []),
}))
);

// console.log("sections", JSON.stringify(sections));
sections.forEach(({ folder, name, props }) => {
sections.forEach(({ folder, name, props, required }) => {
delete props.type;
delete props.kind;
var foldername = `src/reference/config/${folder.replaceAll(".", "/")}`;
var filename = `${name}.md`;
var filePath = `${foldername}/${filename}`;
// console.log(filePath, props);
var schemaAttrs = getObjProps(null, props, []);
var schemaAttrs = getObjProps(null, props, required);
if (fs.existsSync(filePath)) {

var fullMdContent = fs.readFileSync(filePath, "utf8")
Expand Down
53 changes: 32 additions & 21 deletions .check-schema/zilla-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -979,10 +979,10 @@
]
},
"key": {
"$ref": "#/$defs/converter/model"
"$ref": "#/$defs/converter"
},
"value": {
"$ref": "#/$defs/converter/model"
"$ref": "#/$defs/converter"
}
}
}
Expand Down Expand Up @@ -1083,7 +1083,6 @@
"additionalProperties": false
},
"tls": {
"type": "object",
"properties": {
"version": {
"title": "Version",
Expand Down Expand Up @@ -2231,7 +2230,7 @@
"type": "object",
"patternProperties": {
"^[a-zA-Z]+[a-zA-Z0-9\\._\\-]*$": {
"$ref": "#/$defs/validator/model"
"$ref": "#/$defs/validator"
}
}
},
Expand All @@ -2242,23 +2241,23 @@
"type": "object",
"patternProperties": {
"^[a-zA-Z]+[a-zA-Z0-9\\._\\-]*$": {
"$ref": "#/$defs/validator/model"
"$ref": "#/$defs/validator"
}
}
},
"query": {
"type": "object",
"patternProperties": {
"^[a-zA-Z]+[a-zA-Z0-9\\._\\-]*$": {
"$ref": "#/$defs/validator/model"
"$ref": "#/$defs/validator"
}
}
}
},
"additionalProperties": false
},
"content": {
"$ref": "#/$defs/validator/model"
"$ref": "#/$defs/validator"
},
"responses": {
"type": "array",
Expand Down Expand Up @@ -2288,12 +2287,12 @@
"type": "object",
"patternProperties": {
"^[a-zA-Z]+[a-zA-Z0-9\\._\\-]*$": {
"$ref": "#/$defs/validator/model"
"$ref": "#/$defs/validator"
}
}
},
"content": {
"$ref": "#/$defs/validator/model"
"$ref": "#/$defs/validator"
}
},
"anyOf": [
Expand Down Expand Up @@ -2794,10 +2793,10 @@
"type": "string"
},
"key": {
"$ref": "#/$defs/converter/model"
"$ref": "#/$defs/converter"
},
"value": {
"$ref": "#/$defs/converter/model"
"$ref": "#/$defs/converter"
}
}
}
Expand Down Expand Up @@ -3005,12 +3004,10 @@
"title": "Entry",
"type": "string",
"pattern": "^[a-zA-Z]+[a-zA-Z0-9\\._\\-]*$"
},
"required": [
"entry"
]
}
},
"required": [
"entry",
"routes"
]
}
Expand Down Expand Up @@ -3143,13 +3140,13 @@
"type": "string"
},
"content": {
"$ref": "#/$defs/validator/model"
"$ref": "#/$defs/validator"
},
"user-properties": {
"type": "object",
"patternProperties": {
"^[a-zA-Z]+[a-zA-Z0-9\\._\\-]*$": {
"$ref": "#/$defs/validator/model"
"$ref": "#/$defs/validator"
}
}
}
Expand Down Expand Up @@ -3840,7 +3837,7 @@
"type": "string"
},
"content": {
"$ref": "#/$defs/validator/model"
"$ref": "#/$defs/validator"
}
},
"anyOf": [
Expand Down Expand Up @@ -4386,6 +4383,14 @@
]
},
"converter": {
"oneOf": [
{
"$ref": "#/$defs/converter/types"
},
{
"$ref": "#/$defs/converter/model"
}
],
"types": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -4618,7 +4623,7 @@
"pattern": "((?:\\(|\\[))(-?\\d+)?,(-?\\d+)?((?:\\)|\\]))"
},
"multiple": {
"type": "number"
"type": "integer"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -4841,16 +4846,22 @@
}
},
"validator": {
"oneOf": [
{
"$ref": "#/$defs/validator/types"
},
{
"$ref": "#/$defs/validator/model"
}
],
"types": {
"type": "string",
"enum": [
"avro",
"double",
"float",
"int32",
"int64",
"json",
"protobuf",
"string"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Topic name.

#### topics[].key

> `object`
> `enum` [ `avro`, `double`, `float`, `int32`, `int64`, `json`, `protobuf`, `string` ], `object`
Enforce validation for key

Expand All @@ -18,7 +18,7 @@ A schema or type to validate the topic's key. Refer to the individual [model](..

#### topics[].value

> `object`
> `enum` [ `avro`, `double`, `float`, `int32`, `int64`, `json`, `protobuf`, `string` ], `object`
Enforce validation for value

Expand All @@ -27,7 +27,3 @@ Enforce validation for value
> `enum` [ `avro`, `double`, `float`, `int32`, `int64`, `json`, `protobuf`, `string` ]
A schema or type to validate the topic's value. Refer to the individual [model](../../models) docs for type specific implementation.

#### topics[].transforms

> `array`
4 changes: 4 additions & 0 deletions src/reference/config/bindings/asyncapi/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Topic configuration.

Fetch offset to use for new consumers

#### topics[].transforms

> `array`

#### kafka.sasl

> `object`
Expand Down
4 changes: 4 additions & 0 deletions src/reference/config/bindings/asyncapi/proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Topic configuration.

Fetch offset to use for new consumers

#### topics[].transforms

> `array`

#### kafka.sasl

> `object`
Expand Down
4 changes: 4 additions & 0 deletions src/reference/config/bindings/asyncapi/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Topic configuration.

Fetch offset to use for new consumers

#### topics[].transforms

> `array`

#### kafka.sasl

> `object`
Expand Down
5 changes: 3 additions & 2 deletions src/reference/config/bindings/grpc-kafka/.partials/routes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!-- markdownlint-disable MD024 -->
### routes
### routes\*

> `array` of `object`
Expand Down Expand Up @@ -192,11 +191,13 @@ with:
reply-to: responses
```

<!-- markdownlint-disable MD024 -->
#### with.topic\*

> `string`

The name of a Kafka topic for requests.
<!-- markdownlint-enable MD024 -->

#### with.acks

Expand Down
5 changes: 3 additions & 2 deletions src/reference/config/bindings/http-kafka/.partials/routes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!-- markdownlint-disable MD024 -->
### routes
### routes\*

> `array` of `object`
Expand Down Expand Up @@ -244,11 +243,13 @@ with:
location: /items/${params.id};cid=${correlationId}
```

<!-- markdownlint-disable MD024 -->
#### with.topic\*

> `string`

Kafka topic name, optionally referencing path parameter such as `${params.topic}`.
<!-- markdownlint-enable MD024 -->

#### with.acks

Expand Down
Loading

0 comments on commit 50ac3b7

Please sign in to comment.