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
Models: do we need the interfaces extending Map? #248
Comments
Yep - I think the only time we should have an interface that extends |
@EricWittmann : thank you for the "extensible" pointer. I divided my list into two categories: 1) Not extensible. No extends Extensible in the current code:
For:
As discussed in #245 it is marked as extensible for the moment, but this is wrong according to the spec. 2) Extensible.
Extensible in the current code and marked as such in the OpenAPI-Spec. I would like to understand how an extension on the |
+1 for replacing the non-extensible model interfaces with a map version in the appropriate encapsulating model. For the extensible (as per OAS3 spec) model interfaces, I propose that we don't extend from |
For I opened #251 to start tracking future 2.0 candidates - I think this one fits that. |
|
I am OK with this, can we sketch how the methods should look like? Example with Current situation:
Operation that can be added with 1.1:
Not sure how we can make clear that the With version Is this what you have in mind? |
Yup, that's what I was thinking about. I wonder if For |
If it returns |
To continue the discussion, I have opened #266 where I have made the change for |
Agreed in the Sept. 10 hangout with the agreed direction of deprecating the Map extension in |
For the discussion in previous comment #248 (comment) Was something said in the Hangout? In PR #266, I have decided to use: Paths addPathItems(Map<String, PathItem> items); Instead of void setPathItems(Map<String, PathItem> items); Is this the way to go? |
@jmini - we didn't discuss that particular scenario, but my suggestion is to use |
Thinking a bit more, I guess it depends on what the semantics we want to have. Something like |
In my opinion we do not need to have both: Paths addPathItems(Map<String, PathItem> items);
void setPathItems(Map<String, PathItem> items); This will be confusing. The builder pattern make sense for the single add item, using this method: See this example (from the TCK): .paths(OASFactory.createObject(Paths.class)
.addPathItem("/modelReader/airlines", OASFactory.createObject(PathItem.class)
.GET(OASFactory.createObject(Operation.class)
.summary("Retrieve all available airlines")
.operationId("getAirlines")
.responses(OASFactory.createObject(APIResponses.class)
.addAPIResponse("404", OASFactory.createObject(APIResponse.class)
.description("No airlines found")
.content(OASFactory.createObject(Content.class)
.addMediaType("n/a", OASFactory.createObject(MediaType.class)))))))
.addPathItem("/availabilityModel", OASFactory.createObject(PathItem.class)
.GET(OASFactory.createObject(Operation.class)
.tags(new ArrayList<String>())
.addTag("Availability")
.summary("TEST SUMMARY")
.operationId("getTestFlights")
//... I do not see the benefit of having a builder pattern for the Map. Even with the new builder method for Maps ( My recommendation, add a simple setter like this: void setPathItems(Map<String, PathItem> items); If we use a setter method, then it is natural to have a |
yup, agreed. Let's go with that. |
Both PRs has been merged (for |
There are several model interfaces:
Paths
,ServerVariables
,Content
,APIResponses
,Scopes
,Callback
,that extends,
Map<String, T>
My points are:
1/ Those Interfaces are really strange, when working with it, you never can not use stuff like:
Arrays.asList(..)
2/ To implement #240 we might need to remove those interface. How do you create an immutable version of
Paths
3/ The KaiZen-Parser models do not use such a construct.
The text was updated successfully, but these errors were encountered: