Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extend allowed_values option of JSONSchema for Property(ArrayType) #1600

Closed
TyShkan opened this issue Apr 11, 2023 · 2 comments · Fixed by #1603
Closed

feat: extend allowed_values option of JSONSchema for Property(ArrayType) #1600

TyShkan opened this issue Apr 11, 2023 · 2 comments · Fixed by #1603
Labels
kind/Feature New feature or request valuestream/SDK

Comments

@TyShkan
Copy link

TyShkan commented Apr 11, 2023

Feature scope

Taps (catalog, state, stream maps, etc.)

Description

Currently it's not possible to set allowed_values for Property(ArrayType) since it generates schema like following:

"property_name": {
    "type": ["array", "null"],
    "items": {"type": ["string"]},
    "enum": ["allowed_value1", "allowed_value2"]
}

And checks only types like Integer, String, etc, not arrays.

In order to validate array's allowed values the schema should look like following:

"property_name": {
    "type": ["array", "null"],
    "items": {
        "type": ["string"],
        "enum": ["allowed_value1", "allowed_value2"]
    }
}

Looks like the changes should be implemented here:

if self.allowed_values:

Something like:

if self.allowed_values:
    if type is array: # pseudocode
        type_dict["items"].update({"enum": self.allowed_values}) # just a concept
    else:
        type_dict.update({"enum": self.allowed_values})
@TyShkan
Copy link
Author

TyShkan commented Apr 11, 2023

Slack thread

@TyShkan
Copy link
Author

TyShkan commented Apr 12, 2023

Would be solved here: #1603

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/Feature New feature or request valuestream/SDK
Projects
None yet
1 participant