The Wayback Machine - https://web.archive.org/web/20201217020412/https://github.com/springdoc/springdoc-openapi/pull/992
Skip to content
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

OpenApiCustomizer #992

Open
wants to merge 1 commit into
base: master
from

Conversation

@seregamorph
Copy link

@seregamorph seregamorph commented Dec 14, 2020

The problem: OpenApiCustomiser has typo in both interface name and method. The trouble: back compatibility (BC) contracts.
Proposed solution: OpenApiCustomiser (has customise() method) extracted to super-interface OpenApiCustomizer (has customize() method). Deprecated OpenApiCustomiser has customize() method implementation as delegate to obsolete customise(), saving BC.

Kept binary compatibility:
AbstractOpenApiResource constructor (same as its subclasses) now accepts Optional<List<OpenApiCustomizer>> instead of Optional<List<OpenApiCustomiser>>, so in case of iterating the runtime is not broken (cast is possible). It may cause compile issues (Optional<List<OpenApiCustomiser>> is not assignable), but:

  • this way we emphasize the problem to a developer that uses this API
  • binary compatibility kep

⚠️ Compromising binary incompatibility: ⚠️
ActuatorOpenApiCustomizer: now does not extend OpenApiCustomiser, only OpenApiCustomizer. (may be broken in case if this class has subclasses, but it's assumed that it's not reasonable)

Broken binary incompatibility:
OpenApiBuilderCustomizer - customise() -> customize() (here we cannot use the same trick as in OpenApiCustomiser, because it's the same class)

  • Please confirm that you are fine about it, if not, this controversal change may be reverted.
* Will be deleted in 2.0.
*/
@Deprecated
public List<OpenApiCustomiser> getOpenApiCustomisers() {

This comment has been minimized.

@seregamorph

seregamorph Dec 14, 2020
Author

This code smells, but it gives BC.

*/
@Bean
@Lazy(false)
OpenApiCustomiser actuatorOpenApiCustomiser(WebEndpointProperties webEndpointProperties) {
OpenApiCustomizer actuatorOpenApiCustomizer(WebEndpointProperties webEndpointProperties) {

This comment has been minimized.

@seregamorph

seregamorph Dec 14, 2020
Author

may cause compatibility issues because of method renaming, e.g. if class is inherited (will raise compilation issue if @Override annotation is used)

* @author bnasslahsen
*/
public class ActuatorOpenApiCustomizer implements OpenApiCustomiser {
public class ActuatorOpenApiCustomizer implements OpenApiCustomizer {

This comment has been minimized.

@seregamorph

seregamorph Dec 14, 2020
Author

hope this is fine (another interface)

*
* @param openApiService the open api builder
*/
void customise(OpenAPIService openApiService);
void customize(OpenAPIService openApiService);

This comment has been minimized.

@seregamorph

seregamorph Dec 14, 2020
Author

pay attention: broken compatibility here

@@ -36,4 +41,9 @@
*/
void customise(OpenAPI openApi);

@Override
default void customize(OpenAPI openApi) {
customise(openApi);

This comment has been minimized.

@seregamorph

seregamorph Dec 14, 2020
Author

tricky, but fair enough

* @see org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider) org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)
*/
@Bean
@ConditionalOnMissingBean
@Lazy(false)
OpenApiCustomiser linksSchemaCustomiser(HateoasHalProvider halProvider, SpringDocConfigProperties springDocConfigProperties) {
OpenApiCustomizer linksSchemaCustomizer(HateoasHalProvider halProvider, SpringDocConfigProperties springDocConfigProperties) {

This comment has been minimized.

@seregamorph

seregamorph Dec 14, 2020
Author

method renamed (may cause compatibility issues)

*/
private final SpringDocConfigProperties springDocConfigProperties;
@Deprecated
public class OpenApiHateoasLinksCustomiser extends OpenApiHateoasLinksCustomizer implements OpenApiCustomiser {

This comment has been minimized.

@seregamorph

seregamorph Dec 14, 2020
Author

extracted to super-class with correct name


@Override
public void customize(OpenAPI openApi) {
ResolvedSchema resolvedLinkSchema = ModelConverters.getInstance()

This comment has been minimized.

@seregamorph

seregamorph Dec 14, 2020
Author

code moved exactly as-is from OpenApiHateoasLinksCustomiser

@seregamorph
Copy link
Author

@seregamorph seregamorph commented Dec 14, 2020

BTW, CONTRIBUTING.adoc does not declare anything about back compatibility requirements (I believe, they exist).

@bnasslahsen
Copy link
Contributor

@bnasslahsen bnasslahsen commented Dec 14, 2020

@seregamorph,

Thank you for your proposal.
In fact, this is not a typo from an English perspective as both are correct!
But it's due, to the fact of different contributions and we haven't paid this difference in the naming naming during the first merge.

I agree it's better to stick to the same naming rules. Especially that other customizers naming is with "z" letter.
After being found, it doesn't seem to be achievable to keep the backward compatibility with this change.

We will keep your PR Open, in order to schedule it for next major release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.