-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Replace $ref field by reference to jsonReference object #536
Conversation
Thanks for this, but I'm afraid this doesn't work out. As you've noticed, but However, validation wise, the current state is the right one. For For the Path Item Object, the situation is a tad more complicated. We have made a mistake in version 2.0 of the spec by allowing |
It's no really about having other properties in the json reference but more about having a different object. (and maybe if you want to respect the jsonReference, why not setting the additionalProperties to Here is my use case: i have a generator which takes a json schema and transform this into stupid class (pojo / popo / ...) and also handle the serialization / deserialization part. By having the $ref inside the Schema, it's only a property of an existing object, so it's harder (not impossible) to determine if it's a reference or not. However having the separation at an upper level and not in the schema will clearly differentiate a Schema object from a JsonReference object, which is better because you dont handle them the same way. |
While I get your use case (assuming you mean taking the Swagger JSON Schema and generating simple classes for that), however, the changes you propose here would make valid specs render as invalid. |
IMO the last change should be BC compatible with valid specs (about other properties). However it's also less restrictive on json reference. |
Again, the change to the Path Item Object is wrong and does not follow the spec. Personally, I'm not comfortable with merging the PR. The part for the Schema Object is derived from the JSON Schema for JSON Schema itself. The only reason the jsonReference exists in the first place is to define it in places where only that's applicable. I find the change to be adding more complexity to the already-complicated schema to support a specific case rather than to enhance validation, which is the real purpose for the schema. Until the first issue is fixed, I cannot merge the PR. However, even with it fixed, unless more people ask for this kind of explicit separation, I'm not sure it would be wise to merge it still. I'd like to keep the PR open and observe feedback from the community though. If there's demand for it, then by all means it's something to consider. |
This is where tests would really help out. |
I honestly don't think there's room for the PR to be merged, so testing or no testing, it doesn't matter. |
I didn't mean to suggest that this PR should go, but that tests would help signal backwards incompatible changes in the future. |
Tests always help ;) It would definitely make sense to include a more complete set of tests in general, but that would probably go in more in the next iteration of the spec. |
Speaking of the next iteration, do you foresee it still being referred to as a swagger spec? |
No need to foresee, I believe there was an official announcement. It will be officially referred to as the "OpenAPI Specification" (hence the repo name). |
sweet! (sorry to hijack the discussion ;) ) |
No worries ;) |
This allow to have more consistency, and also better tool integration (as it can know a particular path can have a jsonReference)