-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add backcompat stubs for optional header params #967
Conversation
Generate changelog in
|
I'm worried that defining something along these lines may not compile due to multiple equivalent method signatures: testOptionalHeaderParam:
http: POST /test-optional
args:
maybeHeaderOne:
type: optional<string>
param-type: header
param-id: MaybeHeaderOne
maybeHeaderTwo:
type: optional<string>
param-type: header
param-id: MaybeHeaderTwo
maybeQueryOne:
type: optional<string>
param-type: query
maybeQueryTwo:
type: optional<string>
param-type: query |
@@ -56,7 +56,7 @@ protected static void validateGeneratorOutput(List<Path> files, Path outputDir, | |||
Files.deleteIfExists(output); | |||
Files.copy(file, output); | |||
} | |||
assertThat(readFromFile(file)).isEqualTo(readFromFile(output)); | |||
assertThat(readFromFile(file)).describedAs(output.toString()).isEqualTo(readFromFile(output)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if you're aware, we have a helper function to update the expected output ./gradlew test -Drecreate=true
documented here
param-type: query | ||
maybeQuery: | ||
type: optional<rid> | ||
param-type: query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example is generated into the suffixed files, but those are never compiled -- it would be helpful to define this somewhere that outputs into a source set that's also compiled for additional verification, otherwise duplicate methods with the same signature won't be caught by CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you have a place in mind where I could put this example?
I think the cases where type clashes may cause the headers to not compile would be exactly when the first query param is optional and has the same type as any header param. This could be detected in code and worked around by not generating backcompat methods for header params if they would clash. It's likely a corner case in practice, but I appreciate that we need something that always compiles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding it to a new service defined in ete-service.yml should provide compilation verification. Using a new service instead of an existing one means you won't need to update any resource implementations to stub the method.
Is there danger in upgrading from an endpoint with an optional header to an endpoint with an optional header and optional query parameter that the same parameter index and type becomes used for another field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess to be safe you'd want there to always be a non-optional param (of any kind) directly after the last optional header param.
Caught up with @carterkozak via DM. Given the complexities involved in determining whether it's safe to have two dimensions of compatibility backfill methods (headers and query params), we won't be merging this. |
@gsheasby is it one specific library that you're concerned about here? Could we explore a local codegen & relocation workflow to make it invincible to any kind of java ABI/API change? |
@carterkozak - would something like this work, to avoid the concern of equivalent method signatures:
|
Before this PR
Similar to #960 - when an optional Header param is added to a method, no
@Deprecated
method without the header param is generated. This results in dev breaks, requiring any consumers to add eitherOptional.empty()
or the header, as in this commit.After this PR
==COMMIT_MSG==
When optional header params are added, Retrofit and Jersey generated code now includes deprecated methods without these headers - similar to those generated when optional query params are added.
==COMMIT_MSG==
Possible downsides?
Still not added for Dialogue - may split this into another PR.