Comments (5)
Done in #828.
Released in apispec 6.2.0.
Thanks.
from apispec.
Reading "test_callback_schema_v3", it looks like a real schema is required (but not a schema name as string, but full path as string works).
I agree it would be nicer to allow a schema name.
Can't look at it right now (and not on top of my priorities since I don't use callbacks). Would you like to investigate and perhaps add the feature?
from apispec.
@lafrech thank you for having a look.
I had a look at your test and it got me wondering how that test is working because I also had a look at the _resolve_refs_in_operation
and I don't see any mention to callbacks
:
# apispec/core.py
...
def _resolve_refs_in_operation(self, operation) -> None:
if "parameters" in operation:
parameters = []
for parameter in operation["parameters"]:
parameter = self.get_ref("parameter", parameter)
self._resolve_refs_in_parameter_or_header(parameter)
parameters.append(parameter)
operation["parameters"] = parameters
if "requestBody" in operation:
self._resolve_refs_in_request_body(operation["requestBody"])
if "responses" in operation:
responses = {}
for code, response in operation["responses"].items():
response = self.get_ref("response", response)
self._resolve_refs_in_response(response)
responses[code] = response
operation["responses"] = responses
It got me wondering how that test case was even working so I went to check the conftest
:
# tests/confest.py
...
def make_spec(openapi_version):
ma_plugin = MarshmallowPlugin()
spec = APISpec(
title="Validation",
version="0.1",
openapi_version=openapi_version,
plugins=(ma_plugin,),
)
return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))(
spec, ma_plugin, ma_plugin.converter
)
@pytest.fixture(params=("2.0", "3.0.0"))
def spec_fixture(request):
return make_spec(request.param)
So that test case in question is testing MarshmallowPlugin
which it does contain some spec resolution for callbacks so that is why that test case works. The bug is that apispec.core
does not resolve callbacks and it needs to be added.
I can implement that condition and create a test case for apispec.core
, no problem !
Also would you know why does MarchmallowPlugin
implement a schema resolver? To me that seems redundant considering apispec.core
already provides logic to resolve schemas. Having MarchmallowPlugin
schema resolver override the core resolver can lead to inconsistencies as seen in the example above. Would you know what motivated the decision to have MarchmallowPlugin
a schema resolver of its own?
from apispec.
Oh, right.
The point of the marshmallow schema resolver is to transform a Schema object into a dict or a ref. You're right that transforming a string into a ref should be done by core.
from apispec.
PR #828 can close this issue
from apispec.
Related Issues (20)
- Issue with nested self-referencing schemas HOT 2
- Marshmallow plugin doesn't document the format of fields.DateTime() correctly HOT 3
- marshmallow plugin does not support `marshmallow.fields.Tuple` HOT 1
- What is the correct way to use add_attribute_function in the Marshmallow plugin? HOT 2
- additionalProperties=false is not set when using default Marshmallow schema options HOT 2
- wrong default value for 'name' in schema2parameters HOT 3
- parameters not being resolved for OAS3 'content' type parameters HOT 2
- Incorrect handling of marshmallow nested schema with allow_none=True in OpenAPI 3.1 HOT 4
- Incorrect handling of Union types HOT 2
- Deprecated flag is not configured correctly on query parameter objects
- sdist is missing `tox.ini` HOT 1
- Interest in taking Schema description from Schema.__doc__ docstring
- Incorrectly serialized format when using a range validator on a Decimal Marshmallow field HOT 10
- Document form data and images
- Enum by_value creates OpenAPI property without type HOT 11
- Deprecate __version__ attribute
- Add requestBody component HOT 14
- How to get Schema added to components/parameters? HOT 5
- Thanks for the report! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apispec.