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
Test-Json string format not matching #19888
Comments
There seems to be an issue regarding sending |
the same behavior happens when piping a file to the command: > Get-content .\schema.json
{
"type": "object",
"additionalProperties":false,
"properties": {
"duration": {
"type": "string",
"format": "duration"
}
}
}
> Get-content .\data.json
{"duration":"test123"}
> Get-content .\data.json | Test-Json -SchemaFile .\schema.json
True |
Can you please revise the title of this issue, as it's a bit too specific, it'll likely cause many copies of it |
@brian6932 PS > echo "{"duration":"test"}" | Test-Json -SchemaFile .\schema.json
Test-Json: Cannot parse the JSON.
False
Test-Json: Cannot parse the JSON.
False
PS > echo '{"duration":"test"}' | Test-Json -SchemaFile .\schema.json
True |
After some more digging I have noticed that none of the json shema string format options are working in 7.4.0-preview.4 |
/cc @gregsdennis |
In JSON Schema, The two solutions I see here are:
The fix is pretty easy; we just need to decide which to do. |
@gregsdennis Thanks! I hope WG will do a conclusion. /cc @SteveL-MSFT |
|
Uh... what was the fix? Where was it implemented (e.g. a PR)? |
Not sure, but I don't have any issues with nesting quote types anymore |
Oh, so your problem is with quotes in general, which isn't what this issue is about. |
It seemed like the same underlying cause |
Is there still the need for a fix/WG discussion, or was is just a quoting issue? |
@TobiasPSP This is still definitely a problem, and the quotes issue @brian6932 was experiencing was a red herring I believe.
I agree with @FormindAPE that it was mostly working in 7.3.x, I tried 7.3.6 that I had lying around and Using this {
"type": "object",
"additionalProperties": false,
"properties": {
"duration": {
"type": "string",
"format": "duration"
},
"datetest": {
"type": "string",
"format": "date-time"
}
}
} In PowerShell 7.3.6: PS > Test-Json -SchemaFile .\schema.json -Json '{"datetest":"test123"}'
Test-Json: DateTimeExpected: #/datetest
False
PS > Test-Json -SchemaFile .\schema.json -Json '{"duration":"test123"}'
True In PowerShell 7.4.0: PS > Test-Json -SchemaFile .\schema.json -Json '{"datetest":"test123"}'
True
PS > Test-Json -SchemaFile .\schema.json -Json '{"duration":"test123"}'
True
@gregsdennis My vote is for doing 1, in a patch version of PowerShell 7.4.x, since this is essentially a possible unintentional breaking change from 7.3.x. then do 2 in maybe 7.5 or something like that? |
I don't mind doing both of these as a single update, but I would need someone from the PS team to confirm. |
cc: @iSazonov ☝️ |
From document referenced above:
So I think it is optional feature for the cmdlet too. In any case we need WG conclusion. |
To be clear, this isn't about unknown formats, it's about validating The docs:
The spec requires that Since, generally, the default meta-schemas do not reference the @pearj is arguing that previous versions of PowerShell validated I'm happy to have validation enabled by default, if that's what PowerShell wants to do, but it needs to have a switch to disable it. (Personally I feel this is backwards, but I understand the historical context.) |
@gregsdennis Yes you are right, going to the WG sounded like it could take a long time, so I was hoping to restore functionality in a quicker timeframe. But if either change requires WG approval then off by default probably makes the most sense then. |
Prerequisites
Steps to reproduce
Let's create a very simple json schema that use the string format
duration
:the format
duration
was added in the json schema "draft 2019-09" current version is "draft 2020-12". The goal of theduration
format is to match ISO 8601 (see: json schema documentation )and save it in a file named
schema.json
and run the following command to test:
or
the result will be
True
when expectingFalse
Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: