Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
OpenApiCustomizer #992
OpenApiCustomizer #992
Conversation
* Will be deleted in 2.0. | ||
*/ | ||
@Deprecated | ||
public List<OpenApiCustomiser> getOpenApiCustomisers() { |
seregamorph
Dec 14, 2020
Author
This code smells, but it gives BC.
This code smells, but it gives BC.
*/ | ||
@Bean | ||
@Lazy(false) | ||
OpenApiCustomiser actuatorOpenApiCustomiser(WebEndpointProperties webEndpointProperties) { | ||
OpenApiCustomizer actuatorOpenApiCustomizer(WebEndpointProperties webEndpointProperties) { |
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)
@Override
annotation is used)
* @author bnasslahsen | ||
*/ | ||
public class ActuatorOpenApiCustomizer implements OpenApiCustomiser { | ||
public class ActuatorOpenApiCustomizer implements OpenApiCustomizer { |
seregamorph
Dec 14, 2020
Author
hope this is fine (another interface)
hope this is fine (another interface)
* | ||
* @param openApiService the open api builder | ||
*/ | ||
void customise(OpenAPIService openApiService); | ||
void customize(OpenAPIService openApiService); |
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); |
seregamorph
Dec 14, 2020
Author
tricky, but fair enough
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) { |
seregamorph
Dec 14, 2020
Author
method renamed (may cause compatibility issues)
method renamed (may cause compatibility issues)
*/ | ||
private final SpringDocConfigProperties springDocConfigProperties; | ||
@Deprecated | ||
public class OpenApiHateoasLinksCustomiser extends OpenApiHateoasLinksCustomizer implements OpenApiCustomiser { |
seregamorph
Dec 14, 2020
Author
extracted to super-class with correct name
extracted to super-class with correct name
|
||
@Override | ||
public void customize(OpenAPI openApi) { | ||
ResolvedSchema resolvedLinkSchema = ModelConverters.getInstance() |
seregamorph
Dec 14, 2020
Author
code moved exactly as-is from OpenApiHateoasLinksCustomiser
code moved exactly as-is from OpenApiHateoasLinksCustomiser
BTW, CONTRIBUTING.adoc does not declare anything about back compatibility requirements (I believe, they exist). |
Thank you for your proposal. I agree it's better to stick to the same naming rules. Especially that other customizers naming is with "z" letter. We will keep your PR Open, in order to schedule it for next major release. |
The problem:
OpenApiCustomiser
has typo in both interface name and method. The trouble: back compatibility (BC) contracts.Proposed solution:
OpenApiCustomiser
(hascustomise()
method) extracted to super-interfaceOpenApiCustomizer
(hascustomize()
method). DeprecatedOpenApiCustomiser
hascustomize()
method implementation as delegate to obsoletecustomise()
, saving BC.Kept binary compatibility:
AbstractOpenApiResource constructor (same as its subclasses) now accepts
Optional<List<OpenApiCustomizer>>
instead ofOptional<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:ActuatorOpenApiCustomizer: now does not extend
OpenApiCustomiser
, onlyOpenApiCustomizer
. (may be broken in case if this class has subclasses, but it's assumed that it's not reasonable)OpenApiBuilderCustomizer -
customise()
->customize()
(here we cannot use the same trick as inOpenApiCustomiser
, because it's the same class)