Openapi convenience#1230
Conversation
https://spec.openapis.org/oas/v3.1.0.html#parameter-object >>> A parameter MUST contain either a schema property, or a content property, but not both. Add more convenience methods
| } | ||
|
|
||
| def withSummary(updated: String) = copy(summary = Some(updated)) | ||
| def withDescription(updated: String) = copy(description = Some(updated)) |
There was a problem hiding this comment.
I'm wondering if the name here should be withDescription or just description? We already have some def description(s: String) methods out there, and it would be good to have a uniform approach. I'm fine with either, though we would need to come up with some naming conventions.
There was a problem hiding this comment.
agreed, in http4s we have started using with* prefixed methods on our domain types.
Others might prefer the unprefixed version.
Lets choose one and stick with that.
There was a problem hiding this comment.
I think I'd go with unprefixed, since we already have them e.g. in EndpointTransput.description etc
There was a problem hiding this comment.
ok, should that include the add* methods as well, or do we keep them as is?
There was a problem hiding this comment.
I think add* is fine, as it is strictly different in what it's doing from the other ones
|
Thanks! Looks good :) Replying to some of the points:
|
|
Re: validation Following parse not validate, we should be correct by construction, not validate after the fact. But ergonomics matter, and having to jump into for comprehensions for constructing these types are maybe worse? I dont know. Having a separate validator is useful maybe regardless of direction. |
Me neither :) Let's maybe keep this is as a separate issue. We can always do a spike, and see how the results feel like. |
This reverts commit b6db4ee.
Make the OpenApi types a bit more easy to work with.
Breaking:
Made Operation.operationId since this is optional in the spec, but was required in the api.
Made most case classes final, so we can rely on users not trying to extend them.
Added default values where it was possible
Schema of Parameter is optional if content is supplied
Considerations:
Parameter is probably an ADT since it has two modes of operation, with Schema or with Content.
Validation of uniqueness of Operation.operationId should be done somewhere, as uniqueness is required within one document