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

[R] fix warnings in DESCRIPTION #12380

Merged
merged 3 commits into from May 17, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -17,6 +17,10 @@

package org.openapitools.codegen.languages;

import com.samskivert.mustache.Mustache.Lambda;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;

import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
Expand All @@ -33,6 +37,8 @@
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.util.*;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -232,6 +238,17 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("api_client.mustache", File.separator + "R", "api_client.R"));
supportingFiles.add(new SupportingFile("NAMESPACE.mustache", "", "NAMESPACE"));
supportingFiles.add(new SupportingFile("testthat.mustache", File.separator + "tests", "testthat.R"));

// add lambda for mustache templates to fix license field
additionalProperties.put("lambdaLicense", new Mustache.Lambda() {
@Override
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
String content = fragment.execute();
content = content.trim().replace("Apache-2.0", "Apache License 2.0");
writer.write(content);
}
});

}

@Override
Expand Down
@@ -1,13 +1,14 @@
Package: {{{packageName}}}
Title: R Package Client for {{{appName}}}
Version: {{packageVersion}}
Authors@R: person("{{infoName}}{{^infoName}}OpenAPI Generator community{{/infoName}}", email = "{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}", role = c("aut", "cre"))
Author: person("{{infoName}}{{^infoName}}OpenAPI Generator community{{/infoName}}", email = "{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}", role = c("aut", "cre"))
Maintainer: {{infoName}}{{^infoName}}OpenAPI Generator community{{/infoName}} <{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}>
Description: {{{appDescription}}}{{^appDescription}}R Package Client for {{{appName}}}{{/appDescription}}
URL: https://{{{gitHost}}}/{{{gitUserId}}}/{{{gitRepoId}}}
BugReports: https://{{{gitHost}}}/{{{gitUserId}}}/{{{gitRepoId}}}/issues
Depends: R (>= 3.3)
Encoding: UTF-8
License: {{licenseInfo}}{{^licenseInfo}}Unlicense{{/licenseInfo}}
License: {{#lambdaLicense}}{{licenseInfo}}{{/lambdaLicense}}{{^licenseInfo}}Unlicense{{/licenseInfo}}
LazyData: true
Suggests: testthat
Imports: jsonlite, httr, R6, base64enc{{#useRlangExceptionHandling}}, rlang{{/useRlangExceptionHandling}}
Expand Down
@@ -1,5 +1,4 @@
library(testthat)
library(rjson)
library({{{packageName}}})

test_check("{{{packageName}}}")
5 changes: 3 additions & 2 deletions samples/client/petstore/R/DESCRIPTION
@@ -1,13 +1,14 @@
Package: petstore
Title: R Package Client for OpenAPI Petstore
Version: 1.0.0
Authors@R: person("OpenAPI Generator community", email = "team@openapitools.org", role = c("aut", "cre"))
Author: person("OpenAPI Generator community", email = "team@openapitools.org", role = c("aut", "cre"))
Maintainer: OpenAPI Generator community <team@openapitools.org>
Description: This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
URL: https://github.com/GIT_USER_ID/GIT_REPO_ID
BugReports: https://github.com/GIT_USER_ID/GIT_REPO_ID/issues
Depends: R (>= 3.3)
Encoding: UTF-8
License: Apache-2.0
License: Apache License 2.0
LazyData: true
Suggests: testthat
Imports: jsonlite, httr, R6, base64enc
Expand Down
1 change: 0 additions & 1 deletion samples/client/petstore/R/tests/testthat.R
@@ -1,5 +1,4 @@
library(testthat)
library(rjson)
library(petstore)

test_check("petstore")
2 changes: 1 addition & 1 deletion samples/client/petstore/R/tests/testthat/test_petstore.R
Expand Up @@ -94,7 +94,7 @@ test_that("GetPetById", {
test_that("GetPetById with data_file", {
# test to ensure json is saved to the file `get_pet_by_id.json`
petResponse <- petApi$GetPetById(petId, data_file="get_pet_by_id.json")
response <- fromJSON(file = "get_pet_by_id.json")
response <- read_json("get_pet_by_id.json")
expect_true(!is.null(response))
expect_equal(response$id, petId)
expect_equal(response$name, "name_test")
Expand Down