From 49d17fc46bbcd36867f6ac5ef61c7a272742a45b Mon Sep 17 00:00:00 2001 From: kaldebert Date: Wed, 27 Dec 2017 10:56:01 +0100 Subject: [PATCH] Add documentation link in discovery files --- .../google/api/server/spi/discovery/DiscoveryGenerator.java | 6 +++++- .../com/google/api/server/spi/discovery/foo_endpoint.json | 1 + .../server/spi/discovery/foo_endpoint_default_context.json | 1 + .../api/server/spi/discovery/foo_endpoint_localhost.json | 1 + .../java/com/google/api/server/spi/testing/FooEndpoint.java | 3 ++- 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/endpoints-framework/src/main/java/com/google/api/server/spi/discovery/DiscoveryGenerator.java b/endpoints-framework/src/main/java/com/google/api/server/spi/discovery/DiscoveryGenerator.java index c62cdf28..5efa5762 100644 --- a/endpoints-framework/src/main/java/com/google/api/server/spi/discovery/DiscoveryGenerator.java +++ b/endpoints-framework/src/main/java/com/google/api/server/spi/discovery/DiscoveryGenerator.java @@ -154,6 +154,9 @@ private RestDescription writeApi(ApiKey apiKey, Iterable apiConfigs, if (config.getTitle() != null) { doc.setTitle(config.getTitle()); } + if (config.getDocumentationLink() != null) { + doc.setDocumentationLink(config.getDocumentationLink()); + } if (config.getNamespaceConfig() != null) { ApiNamespaceConfig namespaceConfig = config.getNamespaceConfig(); if (!Strings.isEmptyOrWhitespace(namespaceConfig.getOwnerName())) { @@ -392,7 +395,8 @@ private DirectoryList generateDirectory(Map discoveryDo .setName(doc.getName()) .setPreferred(preferred.contains(entry.getKey())) .setTitle(doc.getTitle()) - .setVersion(doc.getVersion())); + .setVersion(doc.getVersion()) + .setDocumentationLink(doc.getDocumentationLink())); } return directory.setItems(items); } diff --git a/endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/foo_endpoint.json b/endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/foo_endpoint.json index acaf574b..6298aa6e 100644 --- a/endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/foo_endpoint.json +++ b/endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/foo_endpoint.json @@ -13,6 +13,7 @@ "batchPath": "batch", "description": "Just Foo Things", "discoveryVersion": "v1", + "documentationLink": "https://example.com", "icons": { "x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png", "x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png" diff --git a/endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/foo_endpoint_default_context.json b/endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/foo_endpoint_default_context.json index baf28645..6ed2099e 100644 --- a/endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/foo_endpoint_default_context.json +++ b/endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/foo_endpoint_default_context.json @@ -13,6 +13,7 @@ "batchPath": "batch", "description": "Just Foo Things", "discoveryVersion": "v1", + "documentationLink": "https://example.com", "icons": { "x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png", "x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png" diff --git a/endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/foo_endpoint_localhost.json b/endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/foo_endpoint_localhost.json index 0f9a2d01..ce1aed6c 100644 --- a/endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/foo_endpoint_localhost.json +++ b/endpoints-framework/src/test/resources/com/google/api/server/spi/discovery/foo_endpoint_localhost.json @@ -13,6 +13,7 @@ "batchPath": "batch", "description": "Just Foo Things", "discoveryVersion": "v1", + "documentationLink": "https://example.com", "icons": { "x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png", "x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png" diff --git a/test-utils/src/main/java/com/google/api/server/spi/testing/FooEndpoint.java b/test-utils/src/main/java/com/google/api/server/spi/testing/FooEndpoint.java index ab4fd3b2..e8e34486 100644 --- a/test-utils/src/main/java/com/google/api/server/spi/testing/FooEndpoint.java +++ b/test-utils/src/main/java/com/google/api/server/spi/testing/FooEndpoint.java @@ -27,7 +27,8 @@ version = "v1", audiences = {"audience"}, title = "The Foo API", - description = "Just Foo Things") + description = "Just Foo Things", + documentationLink = "https://example.com") public class FooEndpoint { @ApiMethod(name = "foo.create", description = "create desc", path = "foos/{id}", httpMethod = HttpMethod.PUT)