-
Notifications
You must be signed in to change notification settings - Fork 3
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
Null values in Axes, properties, x, anyOf, type #8
Comments
How I read the spec, all axes are optional, including the X-axis: In the Common Domain Type section, X and Y are not used for a bunch of the supported domain types: The null in the openapi file appears because of this: We use this approach (instead of just a dictionary) to have control of what the difference axis types can contain (so that we can enforce dates in the "t" axis, etc). I don't see how this strictly violates the spec, as we are just saying that these axis are possible, and if they are given (not-null), they not to comply with some requirements. I can see why this might not be what the EDR validator expects to see in the spec file. But as the produced JSON complies with the CoverageJSON specification, maybe it is fair to say the validator is to strict? We haven't tried EDR validation against our code, and we don't use API code generation, so we have not seen this problem ourselves. What is the error the validator is giving? |
ValidatorThe official validator is at https://cite.opengeospatial.org/teamengine/about/ogcapi-edr10/1.0/site/index.html We have a dockerized version (which I hope can be published, instead of having to compile that java project) which gives this output for my API. See attachments. A summary of the errors:
|
API code generationI won't be using any code generation myself, but users of the API might. Therefore I think it's important that it works. For generating I did this (below). The "/local/" in out is correct though it seems wrong. Files will end up in sub-dir of current dir, as out/go.
Then to compile:
This looks like the same problem to me, though I haven't investigated closely. |
So to work around this do I have to sub-class Axis without a default value? I guess then I also have to sub-class Domain to use my "new" Axis. Are there less dirty ways of doing this? |
Thanks for looking into this and the extra info. How do you know the error ( The openapi.json you point to in your first post has less than 3000 lines (so no line 5297), and the required pattern in the error message does not look appropriate for the Axis value. |
That would be really nice! |
This looks broader then just the Axis, even broader then the CoverageJSON package. For example, the reference to |
The json file is actually unformatted, all on one line. 1:5297 refers to line 1, character 5297. It matches the first null value, and there's a repeated message for each null in the file. |
Ah yes, missed that it is all referring to line 1. |
Raw file from latest version: https://gist.github.com/ways/7acff3af6fc404a283096f5fa5afa2a7 And start of errors for that version:
|
Thanks for sending that. It looks like anywhere we have an optional type in Pydantic, we get this There are several issues about this, for example: I am looking if there is a nice way to fix this. |
I found a way to fix this, by explicitly dropping the Strictly speaking, the schema generated is now not compatible with the pydantic type, but it does produce an openapi spec that looks more like what people expect. So I am not sure what direction we want to go with this yet, as the openapi spec that is currently generated is correct, but uses a new feature that is not yet supported by a lot of tools. But it would be nice to know if this at least solves the problems you indicated. Would you be able to test that? |
Your PR does not break my code and removes null in the spec. The validator seems happy, but of course complains on nulls from edr_pydantic. Openapi.json generated with this pr: https://gist.github.com/ways/3207b68e32443d77e268501db8cdb9a2 I've also opened a bug report for the validator, in case that is where the problem really should be fixed. opengeospatial/ets-ogcapi-edr10#113 |
Seems null is allowed in openapi 3.1, but not in openapi 3.0. Reference: https://redocly.com/docs/openapi-visual-reference/null/ |
Yes, that explains why tooling (like EDR validator and code generators) fail on this, they haven't updated to support the latest spec. We are a bit unclear on how to proceed. The current generated openapi more correctly describes the API and it is correct according to the openapi 3.1 standard. On the other hand, it breaks current tooling, but I guess that will be updated. The "fix" is a nasty hack, and generates an openapi spec document that is not consistent with what the API will accept. But external tooling works better with it. Can we just wait until the tooling is updated? What do you think? |
The validator ticket is now marked as "in progress"... |
Yes, I agree, we can wait and see. |
Does this actually solve the issue for you (at least the EDR validator part)? It looks like any "null" errors are removed. I am trying to build the validator package myself, by no luck so far. |
I will check, but I'm having trouble using the official validators UI. If I understand it correctly, it no longer complains on the null errors. 👍 I will check with the local validator expert when he's available.
Seems you can just pull it from https://hub.docker.com/r/ogccite/ets-ogcapi-edr10 |
Hi
Please se my openapi.json. The relevant code generating this is around this line https://github.com/metno/edrisobaric/blob/f344ca8a414e75b52726a2d727737144bddac8f4/app/routes/position_page.py#L111.
These null values cause trouble in EDR validation and API code generation (https://github.com/OpenAPITools/openapi-generator).
I'm unsure why the null appears. X should not be an optional value. Have you seen the problem in your use, or am I using the library wrong?
The text was updated successfully, but these errors were encountered: