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

#40 Added support for operation deprecation #41

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ object OperationMethodProcessor {
operation.description(annotation.description.ifBlank { null })
operation.operationId(annotation.operationId.ifBlank { null })
operation.summary(annotation.summary.ifBlank { null })
operation.deprecated(annotation.deprecated.takeIf { annotation.deprecated })
operation.externalDocs(
AnnotationsUtils.getExternalDocumentation(annotation.externalDocs)
.orElse(AnnotationsUtils.getExternalDocumentation(classInfo.externalDocumentation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.junit.jupiter.api.Test;
import org.taymyr.lagom.internal.openapi.cases.ArrayParameterService;
import org.taymyr.lagom.internal.openapi.cases.ClassHiddenService;
import org.taymyr.lagom.internal.openapi.cases.DeprecatedOperationService;
import org.taymyr.lagom.internal.openapi.cases.LinksService;
import org.taymyr.lagom.internal.openapi.cases.OpenAPIDefinitionService;
import org.taymyr.lagom.internal.openapi.cases.ParameterService;
Expand Down Expand Up @@ -50,6 +51,17 @@ void testParameterService() throws NoSuchMethodException {
);
}

@Test
@DisplayName("Test service with a deprecated operation")
void testDeprecatedOperationService() throws NoSuchMethodException {
checkOpenAPISpec(
new LagomServiceInfo(DeprecatedOperationService.class, ImmutableList.of(
new LagomCallInfo(DeprecatedOperationService.class.getDeclaredMethod("test", String.class), "/test/{id}", "GET")
)),
"DeprecatedOperationService.yml"
);
}

@Test
@DisplayName("Test service with array parameters")
void testArrayParameterService() throws NoSuchMethodException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.taymyr.lagom.internal.openapi.cases;

import akka.NotUsed;
import com.lightbend.lagom.javadsl.api.Descriptor;
import com.lightbend.lagom.javadsl.api.Service;
import com.lightbend.lagom.javadsl.api.ServiceCall;
import com.lightbend.lagom.javadsl.api.transport.Method;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.enums.ParameterStyle;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.media.Schema;

import static com.lightbend.lagom.javadsl.api.Service.named;
import static com.lightbend.lagom.javadsl.api.Service.restCall;

@OpenAPIDefinition(
info = @Info(title = "Test", version = "1.0.0", description = "Description")
)
public interface DeprecatedOperationService extends Service {

@Operation(
deprecated = true,
parameters = {
@Parameter(
in = ParameterIn.PATH,
name = "id",
required = true,
description = "parameter description",
allowReserved = true,
style = ParameterStyle.SIMPLE,
schema = @Schema(
type = "string",
format = "uuid",
description = "the generated UUID",
accessMode = Schema.AccessMode.READ_ONLY)
)}
)
ServiceCall<NotUsed, NotUsed> test(String id);

@Override
default Descriptor descriptor() {
return named("test").withCalls(
restCall(Method.GET, "/test/:id", this::test)
);
}

}
24 changes: 24 additions & 0 deletions core/src/test/resources/DeprecatedOperationService.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
openapi: 3.0.1
info:
title: Test
description: Description
version: 1.0.0
paths:
/test/{id}:
get:
deprecated: true
operationId: test
parameters:
- name: id
in: path
description: parameter description
required: true
style: simple
allowReserved: true
schema:
type: string
description: the generated UUID
format: uuid
readOnly: true
responses: {}
components: {}