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

Please ignore "anyOf type null" #113

Open
ways opened this issue Jan 18, 2024 · 4 comments
Open

Please ignore "anyOf type null" #113

ways opened this issue Jan 18, 2024 · 4 comments
Assignees

Comments

@ways
Copy link

ways commented Jan 18, 2024

Describe the bug

I generate my openapi spec using pydantic. When there are optional values, pydantic will output such:

"anyOf": [
                {
                  "$ref": "#/components/schemas/ValuesAxis_float_"
                },
                {
                  "$ref": "#/components/schemas/CompactAxis"
                },
                {
                  "type": "null"
                }

The validator does not like this null value, and gives:

Value 'null' does not match required pattern 'boolean|object|array|number|integer|string'

I'm not sure who are correct here, but I think it might be pydantic.

To Reproduce
Steps to reproduce the behavior:

  1. Create a model in pydantic with an optional field.
class Axes(CovJsonBaseModel):
    x: Optional[Union[ValuesAxis[float], CompactAxis]] = None
  1. Look at resulting openapi spec.

Expected behavior

Allow "type: null" if the field is not required.

Additional context

Example openapi.json: https://github.com/metno/edrisobaric/blob/main/docs/openapi.json

@dstenger
Copy link
Collaborator

Thank you for reporting.
We will do further investigation.

@ways
Copy link
Author

ways commented Jan 30, 2024

Seems null is allowed in openapi 3.1, but not in openapi 3.0.

Reference: https://redocly.com/docs/openapi-visual-reference/null/

@bpross-52n bpross-52n mentioned this issue Feb 1, 2024
@ghobona
Copy link
Contributor

ghobona commented Feb 1, 2024

@ways The Executable Test Suite only supports OGC API - Environmental Data Retrieval (EDR) version 1.0.0 and 1.0.1.

These versions of OGC API - EDR only support OpenAPI 3.0.

If you would like future versions of OGC API - EDR to support OpenAPI 3.1, please create a GitHub Issue at https://github.com/opengeospatial/ogcapi-environmental-data-retrieval/issues

@ways
Copy link
Author

ways commented Feb 1, 2024

If you would like future versions of OGC API - EDR to support OpenAPI 3.1, please create a GitHub Issue at https://github.com/opengeospatial/ogcapi-environmental-data-retrieval/issues

Seems that's already discussed here opengeospatial/ogcapi-environmental-data-retrieval#375

I will leave my service as it is, and ignore the validation problem for now.

@dstenger dstenger added this to CITE Aug 1, 2024
@dstenger dstenger moved this to Needs discussion in CITE Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs discussion
Development

Successfully merging a pull request may close this issue.

5 participants