Skip to content

fix(java): add javadoc to all methods APIC-538 #704

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

Merged
merged 8 commits into from
Jun 16, 2022
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
11 changes: 11 additions & 0 deletions templates/java/api_javadoc.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* @throws AlgoliaRuntimeException If it fails to process the API call
{{#isDeprecated}}
* @deprecated
{{/isDeprecated}}
{{#externalDocs}}
* @see <a href="{{url}}">{{{summary}}} Documentation</a> ({{{description}}})
{{/externalDocs}}
*/
{{#isDeprecated}}
@Deprecated
{{/isDeprecated}}
58 changes: 41 additions & 17 deletions templates/java/libraries/okhttp-gson/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,17 @@ public class {{classname}} extends ApiClient {

{{#operation}}
/**
* {{&notes}}{{#allParams}}
* @param {{paramName}} {{&description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#returnType}}
* {{{notes}}}{{#allParams}}
* @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#returnType}}
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
* @return {{.}}{{/returnType}}
* @throws AlgoliaRuntimeException If fail to call the API, e.g. server error or cannot deserialize the response body
{{#isDeprecated}}
* @deprecated
{{/isDeprecated}}
{{#externalDocs}}
* {{&description}}
* @see <a href="{{url}}">{{&summary}} Documentation</a>
* {{{description}}}
* @see <a href="{{url}}">{{{summary}}} Documentation</a>
{{/externalDocs}}
*/
{{#isDeprecated}}
Expand All @@ -155,19 +155,35 @@ public class {{classname}} extends ApiClient {
}

{{! This case only sets `requestOptions` as optional }}
/**
* {{{notes}}}{{#allParams}}
* @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#returnType}}
* @return {{.}}{{/returnType}}
{{> api_javadoc}}
public {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws AlgoliaRuntimeException {
{{#returnType}}return {{/returnType}}this.{{operationId}}({{#allParams}}{{paramName}}, {{/allParams}}null);
}

{{! This case sets `requiredParams` + `requestOptions` }}
{{#optionalParams.0}}
/**
* {{{notes}}}{{#requiredParams}}
* @param {{paramName}} {{{description}}} (required){{/requiredParams}}{{#returnType}}
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
* @return {{.}}{{/returnType}}
{{> api_javadoc}}
public {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}, {{/requiredParams}}RequestOptions requestOptions) throws AlgoliaRuntimeException {
{{#returnType}}return {{/returnType}}this.{{operationId}}({{#requiredParams}}{{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#requiredParams.0}},{{/requiredParams.0}}{{#optionalParams}}null{{^-last}},{{/-last}}{{/optionalParams}}, requestOptions);
}
{{/optionalParams.0}}

{{! This case only sets `requiredParams` }}
{{#optionalParams.0}}
/**
* {{{notes}}}{{#requiredParams}}
* @param {{paramName}} {{{description}}} (required){{/requiredParams}}{{#returnType}}
* @return {{.}}{{/returnType}}
{{> api_javadoc}}
public {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}) throws AlgoliaRuntimeException {
{{#returnType}}return {{/returnType}}this.{{operationId}}({{#requiredParams}}{{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#requiredParams.0}},{{/requiredParams.0}}{{#optionalParams}}null{{^-last}},{{/-last}}{{/optionalParams}}, null);
}
Expand All @@ -178,19 +194,8 @@ public class {{classname}} extends ApiClient {
* {{notes}}{{#allParams}}
* @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
* @return The awaitable future
* @throws AlgoliaRuntimeException If fail to process the API call, e.g. serializing the request body object
{{#isDeprecated}}
* @deprecated
{{/isDeprecated}}
{{#externalDocs}}
* {{&description}}
* @see <a href="{{url}}">{{&summary}} Documentation</a>
{{/externalDocs}}
*/
{{#isDeprecated}}
@Deprecated
{{/isDeprecated}}
* @return CompletableFuture<{{{returnType}}}> The awaitable future
{{> api_javadoc}}
public CompletableFuture<{{{returnType}}}> {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}RequestOptions requestOptions) throws AlgoliaRuntimeException {
{{#allParams}}{{#required}}
if ({{paramName}} == null) {
Expand Down Expand Up @@ -234,19 +239,38 @@ public class {{classname}} extends ApiClient {
}

{{! This case only sets `requestOptions` as optional }}
/**
* (asynchronously)
* {{notes}}{{#allParams}}
* @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
* @return CompletableFuture<{{{returnType}}}> The awaitable future
{{> api_javadoc}}
public CompletableFuture<{{{returnType}}}> {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws AlgoliaRuntimeException {
{{#returnType}}return {{/returnType}}this.{{operationId}}Async({{#allParams}}{{paramName}}, {{/allParams}}null);
}

{{! This case sets `requiredParams` + `requestOptions` }}
{{#optionalParams.0}}
/**
* (asynchronously)
* {{notes}}{{#requiredParams}}
* @param {{paramName}} {{{description}}} (required){{/requiredParams}}
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
* @return CompletableFuture<{{{returnType}}}> The awaitable future
{{> api_javadoc}}
public CompletableFuture<{{{returnType}}}> {{operationId}}Async({{#requiredParams}}{{{dataType}}} {{paramName}}, {{/requiredParams}}RequestOptions requestOptions) throws AlgoliaRuntimeException {
{{#returnType}}return {{/returnType}}this.{{operationId}}Async({{#requiredParams}}{{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#requiredParams.0}},{{/requiredParams.0}}{{#optionalParams}}null{{^-last}},{{/-last}}{{/optionalParams}}, requestOptions);
}
{{/optionalParams.0}}

{{! This case only sets `requiredParams` }}
{{#optionalParams.0}}
/**
* (asynchronously)
* {{notes}}{{#requiredParams}}
* @param {{paramName}} {{{description}}} (required){{/requiredParams}}
* @return CompletableFuture<{{{returnType}}}> The awaitable future
{{> api_javadoc}}
public CompletableFuture<{{{returnType}}}> {{operationId}}Async({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}) throws AlgoliaRuntimeException {
{{#returnType}}return {{/returnType}}this.{{operationId}}Async({{#requiredParams}}{{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#requiredParams.0}},{{/requiredParams.0}}{{#optionalParams}}null{{^-last}},{{/-last}}{{/optionalParams}}, null);
}
Expand Down
2 changes: 1 addition & 1 deletion templates/java/modelEnum.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.google.gson.stream.JsonWriter;
{{/gson}}

/**
* {{&description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
* {{{description}}}{{^description}}Gets or Sets {{{name}}}{{/description}}
*/
{{#gson}}
@JsonAdapter({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.Adapter.class)
Expand Down
2 changes: 1 addition & 1 deletion templates/java/modelInnerEnum.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* {{&description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
* {{{description}}}{{^description}}Gets or Sets {{{name}}}{{/description}}
*/
{{#gson}}
@JsonAdapter({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.Adapter.class)
Expand Down
2 changes: 1 addition & 1 deletion templates/java/pojo.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* {{&description}}{{^description}}{{classname}}{{/description}}{{#isDeprecated}}
* {{{description}}}{{^description}}{{classname}}{{/description}}{{#isDeprecated}}
* @deprecated{{/isDeprecated}}
*/{{#isDeprecated}}
@Deprecated{{/isDeprecated}}
Expand Down
4 changes: 2 additions & 2 deletions templates/javascript/api/operation/jsdoc.mustache
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
{{#notes}}
* {{&notes}}
* {{{notes}}}
{{/notes}}
{{#summary}}
* @summary {{&summary}}
* @summary {{{summary}}}
{{/summary}}
{{#vendorExtensions}}
{{#x-create-wrapping-object}}
Expand Down
4 changes: 2 additions & 2 deletions templates/php/ObjectSerializer.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ObjectSerializer
foreach ($data::openAPITypes() as $property => $openAPIType) {
$getter = $data::getters()[$property];
$value = $data->$getter();
if ($value !== null && !in_array($openAPIType, [{{&primitives}}], true)) {
if ($value !== null && !in_array($openAPIType, [{{{primitives}}}], true)) {
$callable = [$openAPIType, 'getAllowableEnumValues'];
if (is_callable($callable)) {
/** array $callable */
Expand Down Expand Up @@ -305,7 +305,7 @@ class ObjectSerializer
}

/** @psalm-suppress ParadoxicalCondition */
if (in_array($class, [{{&primitives}}], true)) {
if (in_array($class, [{{{primitives}}}], true)) {
settype($data, $class);
return $data;
}
Expand Down