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

SpecError when the result is an array #73

Closed
smurfix opened this issue Mar 4, 2022 · 3 comments · Fixed by #77
Closed

SpecError when the result is an array #73

smurfix opened this issue Mar 4, 2022 · 3 comments · Fixed by #77
Assignees

Comments

@smurfix
Copy link
Contributor

smurfix commented Mar 4, 2022

openapi3.errors.SpecError: Expected paths./phone/batch_locations.post.responses.201.content.application/json.examples.response.value to be one of [Reference,<class 'dict'>,<class 'str'>], got <class 'list'>

The attached file is a reduced version of the spec that exhibits the problem, available from https://marketplace.zoom.us/docs/page-data/api-reference/phone/methods/page-data.json (you need to access R.result.pageContext.OAS.spec, then add an email field to the contact object, duh) where I found the problem.

phone.json.txt

@smurfix
Copy link
Contributor Author

smurfix commented Mar 4, 2022

This might be a stupid question, in which case I'd like to apologize in advance, but … is there a reason why you are not using the jsonschema package for this?

@Dorthu Dorthu self-assigned this Mar 8, 2022
@Dorthu
Copy link
Owner

Dorthu commented Mar 8, 2022

is there a reason why you are not using the jsonschema package for this

Admittedly, no. I'm currently evaluating #69, which reimplements a lot of the core logic here using pydantic (a full usable fork which that branch is based off of is here), but that also does not use the jsonschema package. I'll look into it, as that could simplify a lot.

@Dorthu
Copy link
Owner

Dorthu commented Mar 8, 2022

Looks like the problem here is that the OpenAPI standard defines ax Example type's value as "any" type, but this library only approximates that behavior.

Dorthu added a commit that referenced this issue Mar 8, 2022
Closes #73

The OpenAPI Standard defines a MediaType.example as [any type](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#media-type-object),
and similarly for [Example.value](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#example-object).

This library previously did not implement these types in that way,
instead accepting a broad set of types, but not _actually_ any type -
namely, arrays would break since they are handled specially when parsing
the spec.

This change moves to `"*"` as the accepted type, which is handled as the
special-case "any" type when parsing specs.  This results in the
expected behavior.  A test was added to confirm that arrays are accepted
as expected.
Dorthu added a commit that referenced this issue Mar 8, 2022
Closes #73

The OpenAPI Standard defines a MediaType.example as [any type](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#media-type-object),
and similarly for [Example.value](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#example-object).

This library previously did not implement these types in that way,
instead accepting a broad set of types, but not _actually_ any type -
namely, arrays would break since they are handled specially when parsing
the spec.

This change moves to `"*"` as the accepted type, which is handled as the
special-case "any" type when parsing specs.  This results in the
expected behavior.  A test was added to confirm that arrays are accepted
as expected.
@Dorthu Dorthu closed this as completed in #77 Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants