From 0e9c6dd9a89cdf77ddf17f7df1a2aa7dd07abe60 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sat, 22 Aug 2020 22:14:04 -0400 Subject: [PATCH] [ci] Update gitattributes and allow skipping docs generation for Windows CI workflows (#7273) --- .gitattributes | 29 +- .../workflows/check-supported-versions.yaml | 7 +- bin/utils/ensure-up-to-date | 7 + bin/utils/export_docs_generators.sh | 5 + .../.gitignore | 3 - .../gradlew.bat | 168 +- .../samples/local-spec/gradlew.bat | 200 +- .../codegen/DefaultGenerator.java | 4 +- .../asciidoc/AsciidocGeneratorTest.java | 304 +- .../asciidoc/LinkMarkupFilterTest.java | 94 +- .../codegen/mysql/MysqlSchemaCodegenTest.java | 628 ++-- .../test/resources/3_0/asciidoc/api-docs.json | 2832 ++++++++--------- .../rest/project/GET/GET.json | 30 +- .../rest/project/GET/http-response.adoc | 2 +- .../rest/project/GET/implementation.adoc | 2 +- .../asciidoc/specs/rest/project/GET/spec.adoc | 14 +- mvnw.cmd | 290 +- .../petstore/kotlin-multiplatform/gradlew.bat | 200 +- samples/client/petstore/kotlin/gradlew.bat | 168 +- samples/meta-codegen-kotlin/gradlew.bat | 200 +- .../static/img/companies/angular-schule.svg | 178 +- 21 files changed, 2703 insertions(+), 2662 deletions(-) diff --git a/.gitattributes b/.gitattributes index def43c73b65..727dd54ea14 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,28 @@ -**/*.mustache linguist-vendored=true +* text=auto + +## Windows Specific stuff +*.vcproj text eol=crlf +*.bat text eol=crlf +*.cmd text eol=crlf + +*.txt text eol=lf +*.yaml text eol=lf +*.yml text eol=lf +*.json text eol=lf +*.md text eol=lf +*.xml text eol=lf +gradlew text eol=lf +*.sh text eol=lf +*.properties text eol=lf +*.java text eol=lf +.gitignore text eol=lf +.gradle text eol=lf +.sbt text eol=lf +.scala text eol=lf +.ts text eol=lf +.adoc text eol=lf +.svg text eol=lf + +*.mustache text eol=lf linguist-vendored=true +*.hbs text eol=lf linguist-vendored=true +*.handlebars text eol=lf linguist-vendored=true diff --git a/.github/workflows/check-supported-versions.yaml b/.github/workflows/check-supported-versions.yaml index 0fa05d485eb..5e38634c972 100644 --- a/.github/workflows/check-supported-versions.yaml +++ b/.github/workflows/check-supported-versions.yaml @@ -65,7 +65,10 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest] + include: + - os: windows-latest + flags: --skip-docs steps: - name: Check out code uses: actions/checkout@v2 @@ -79,4 +82,4 @@ jobs: git config core.fileMode false mkdir -p modules/openapi-generator-cli/target/ mv artifact/openapi-generator-cli.jar modules/openapi-generator-cli/target/ - ./bin/utils/ensure-up-to-date + ./bin/utils/ensure-up-to-date ${{ matrix.flags }} diff --git a/bin/utils/ensure-up-to-date b/bin/utils/ensure-up-to-date index 037d1f554e8..3dde0cf2a6d 100755 --- a/bin/utils/ensure-up-to-date +++ b/bin/utils/ensure-up-to-date @@ -19,6 +19,13 @@ if [ $status -ne 0 ]; then exit $status fi +if [[ "--skip-docs" == "${1}" ]]; then + # We export here rather than modify our iterable so that: + # - the scripts can show they ran and echo meaningfully + # - the scripts can do cleanup (if necessary) when skipped + export SKIP_EXPORT_DOCS=true +fi + # Some special case generators may expect to be run as a stanalone process (e.g. modifying classpath) # Docs should always be run, regardless of batch or operation. declare -a always_iterate=( diff --git a/bin/utils/export_docs_generators.sh b/bin/utils/export_docs_generators.sh index 4f211dfa4a8..57283b3ff59 100755 --- a/bin/utils/export_docs_generators.sh +++ b/bin/utils/export_docs_generators.sh @@ -5,6 +5,11 @@ echo "# START SCRIPT: ${SCRIPT}" executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" +if [[ "true" == "${SKIP_EXPORT_DOCS}" ]]; then + echo "Skipping doc exports. Note that docs generated by Windows may break paths as they have not yet been normalized to OS-specific paths." + exit 0 +fi + for GENERATOR in $(java -jar ${executable} list --short --include all | sed -e 's/,/\'$'\n''/g') do ./bin/utils/export_generator.sh ${GENERATOR} diff --git a/modules/openapi-generator-gradle-plugin/.gitignore b/modules/openapi-generator-gradle-plugin/.gitignore index 67bffab9eec..00cb1335fbf 100644 --- a/modules/openapi-generator-gradle-plugin/.gitignore +++ b/modules/openapi-generator-gradle-plugin/.gitignore @@ -110,9 +110,6 @@ hs_err_pid* .AppleDouble .LSOverride -# Icon must end with two \r -Icon - # Thumbnails ._* diff --git a/modules/openapi-generator-gradle-plugin/gradlew.bat b/modules/openapi-generator-gradle-plugin/gradlew.bat index e95643d6a2c..f9553162f12 100644 --- a/modules/openapi-generator-gradle-plugin/gradlew.bat +++ b/modules/openapi-generator-gradle-plugin/gradlew.bat @@ -1,84 +1,84 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/modules/openapi-generator-gradle-plugin/samples/local-spec/gradlew.bat b/modules/openapi-generator-gradle-plugin/samples/local-spec/gradlew.bat index 24467a141f7..9618d8d9607 100644 --- a/modules/openapi-generator-gradle-plugin/samples/local-spec/gradlew.bat +++ b/modules/openapi-generator-gradle-plugin/samples/local-spec/gradlew.bat @@ -1,100 +1,100 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 7e7bf97f64f..7f3cc943e98 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -1352,7 +1352,9 @@ public class DefaultGenerator implements Generator { } }); - String relativeMeta = METADATA_DIR + File.separator + "VERSION"; + // NOTE: Don't use File.separator here as we write linux-style paths to FILES, and File.separator will + // result in incorrect match on Windows machines. + String relativeMeta = METADATA_DIR + "/VERSION"; filesToSort.sort(PathFileComparator.PATH_COMPARATOR); filesToSort.forEach(f -> { String tmp = outDir.toPath().relativize(f.toPath()).normalize().toString(); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/asciidoc/AsciidocGeneratorTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/asciidoc/AsciidocGeneratorTest.java index 782444a6e00..91ab4f87bea 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/asciidoc/AsciidocGeneratorTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/asciidoc/AsciidocGeneratorTest.java @@ -1,152 +1,152 @@ -package org.openapitools.codegen.asciidoc; - -import java.io.File; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.apache.commons.io.FileUtils; -import org.openapitools.codegen.ClientOptInput; -import org.openapitools.codegen.CodegenConfig; -import org.openapitools.codegen.DefaultGenerator; -import org.openapitools.codegen.MockDefaultGenerator; -import org.openapitools.codegen.TestUtils; -import org.openapitools.codegen.config.CodegenConfigurator; -import org.openapitools.codegen.languages.AsciidocDocumentationCodegen; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testng.Assert; -import org.testng.annotations.Test; - -import io.swagger.v3.oas.models.OpenAPI; - -/** unit test asciidoc markup generation against ping.yaml openapi spec. */ -public class AsciidocGeneratorTest { - - private static final Logger LOGGER = LoggerFactory.getLogger(AsciidocGeneratorTest.class); - - @Test - public void testPingSpecTitle() throws Exception { - final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/ping.yaml"); - - AsciidocDocumentationCodegen codeGen = new AsciidocDocumentationCodegen(); - codeGen.preprocessOpenAPI(openAPI); - - Assert.assertEquals(openAPI.getInfo().getTitle(), "ping test"); - } - - @Test - public void testGenerateIndexAsciidocMarkupFileWithAsciidocGenerator() throws Exception { - - File output = Files.createTempDirectory("test").toFile(); - - final CodegenConfigurator configurator = new CodegenConfigurator().setGeneratorName("asciidoc") - .setInputSpec("src/test/resources/3_0/ping.yaml").setOutputDir(output.getAbsolutePath()) - .addAdditionalProperty(AsciidocDocumentationCodegen.SNIPPET_DIR, "MY-SNIPPET-DIR") - .addAdditionalProperty(AsciidocDocumentationCodegen.SPEC_DIR, "MY-SPEC-DIR"); - - final ClientOptInput clientOptInput = configurator.toClientOptInput(); - DefaultGenerator generator = new DefaultGenerator(); - generator.setGenerateMetadata(false); - List generatedFiles = generator.opts(clientOptInput).generate(); - TestUtils.ensureContainsFile(generatedFiles, output, "index.adoc"); - } - - @Test - public void testGenerateIndexAsciidocMarkupContent() throws Exception { - final File output = Files.createTempDirectory("test").toFile(); - output.mkdirs(); - output.deleteOnExit(); - - final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/ping.yaml"); - CodegenConfig codegenConfig = new AsciidocDocumentationCodegen(); - codegenConfig.setOutputDir(output.getAbsolutePath()); - ClientOptInput clientOptInput = new ClientOptInput().openAPI(openAPI).config(codegenConfig); - - DefaultGenerator generator = new DefaultGenerator(); - List files = generator.opts(clientOptInput).generate(); - boolean markupFileGenerated = false; - for (File file : files) { - if (file.getName().equals("index.adoc")) { - markupFileGenerated = true; - String markupContent = FileUtils.readFileToString(file, StandardCharsets.UTF_8); - // check on some basic asciidoc markup content - Assert.assertTrue(markupContent.contains("= ping test"), - "expected = header in: " + markupContent.substring(0, 50)); - Assert.assertTrue(markupContent.contains(":toc: "), - "expected = :toc: " + markupContent.substring(0, 50)); - } - } - Assert.assertTrue(markupFileGenerated, "Default api file is not generated!"); - } - - @Test - public void testAdditionalDirectoriesGeneratedIntoHeaderAttributes() throws Exception { - File output = Files.createTempDirectory("test").toFile(); - - LOGGER.info("test: generating sample markup " + output.getAbsolutePath()); - - Map props = new TreeMap(); - props.put("specDir", "spec"); - - final CodegenConfigurator configurator = new CodegenConfigurator().setGeneratorName("asciidoc") - .setInputSpec("src/test/resources/3_0/ping.yaml").setOutputDir(output.getAbsolutePath()) - .addAdditionalProperty(AsciidocDocumentationCodegen.SPEC_DIR, "SPEC-DIR") - .addAdditionalProperty(AsciidocDocumentationCodegen.SNIPPET_DIR, "MY/SNIPPET/DIR"); - - DefaultGenerator generator = new DefaultGenerator(); - List files = generator.opts(configurator.toClientOptInput()).generate(); - boolean markupFileGenerated = false; - for (File file : files) { - if (file.getName().equals("index.adoc")) { - markupFileGenerated = true; - String markupContent = FileUtils.readFileToString(file, StandardCharsets.UTF_8); - Assert.assertTrue(markupContent.contains(":specDir: SPEC-DIR"), - "expected :specDir: in: " + markupContent.substring(0, 250)); - Assert.assertTrue(markupContent.contains(":snippetDir: MY/SNIPPET/DIR"), - "expected :snippetDir: in: " + markupContent.substring(0, 250)); - } - } - Assert.assertTrue(markupFileGenerated, "index.adoc is not generated!"); - - } - - - @Test - public void testHeaderAttributesFlagRemovesAttributesFromMarkupHeaderSection() throws Exception { - File output = Files.createTempDirectory("test").toFile(); - - LOGGER.info("test: generating sample markup " + output.getAbsolutePath()); - - Map props = new TreeMap(); - props.put("specDir", "spec"); - - final CodegenConfigurator configurator = new CodegenConfigurator() - .setGeneratorName("asciidoc") - .setInputSpec("src/test/resources/3_0/ping.yaml") - .setOutputDir(output.getAbsolutePath()) - .addAdditionalProperty(AsciidocDocumentationCodegen.HEADER_ATTRIBUTES_FLAG, "false") // option avoids generation of attributes - .addAdditionalProperty(AsciidocDocumentationCodegen.SPEC_DIR, "SPEC-DIR") - .addAdditionalProperty(AsciidocDocumentationCodegen.SNIPPET_DIR, "MY/SNIPPET/DIR"); - - DefaultGenerator generator = new DefaultGenerator(); - boolean markupFileGenerated = false; - List files = generator.opts(configurator.toClientOptInput()).generate(); - for (File file : files) { - if (file.getName().equals("index.adoc")) { - markupFileGenerated = true; - String markupContent = FileUtils.readFileToString(file, StandardCharsets.UTF_8); - Assert.assertFalse(markupContent.contains(":specDir: SPEC-DIR"), - "not expected :specDir: in: " + markupContent.substring(0, 250)); - Assert.assertFalse(markupContent.contains(":snippetDir: MY/SNIPPET/DIR"), - "not expected :snippetDir: in: " + markupContent.substring(0, 250)); - Assert.assertFalse(markupContent.contains(":toc:"), - "not expected :toc: in: " + markupContent.substring(0, 250)); // typical attributes not found in markup. - } - } - Assert.assertTrue(markupFileGenerated, "index.adoc is not generated!"); - } - -} +package org.openapitools.codegen.asciidoc; + +import java.io.File; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import org.apache.commons.io.FileUtils; +import org.openapitools.codegen.ClientOptInput; +import org.openapitools.codegen.CodegenConfig; +import org.openapitools.codegen.DefaultGenerator; +import org.openapitools.codegen.MockDefaultGenerator; +import org.openapitools.codegen.TestUtils; +import org.openapitools.codegen.config.CodegenConfigurator; +import org.openapitools.codegen.languages.AsciidocDocumentationCodegen; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.Assert; +import org.testng.annotations.Test; + +import io.swagger.v3.oas.models.OpenAPI; + +/** unit test asciidoc markup generation against ping.yaml openapi spec. */ +public class AsciidocGeneratorTest { + + private static final Logger LOGGER = LoggerFactory.getLogger(AsciidocGeneratorTest.class); + + @Test + public void testPingSpecTitle() throws Exception { + final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/ping.yaml"); + + AsciidocDocumentationCodegen codeGen = new AsciidocDocumentationCodegen(); + codeGen.preprocessOpenAPI(openAPI); + + Assert.assertEquals(openAPI.getInfo().getTitle(), "ping test"); + } + + @Test + public void testGenerateIndexAsciidocMarkupFileWithAsciidocGenerator() throws Exception { + + File output = Files.createTempDirectory("test").toFile(); + + final CodegenConfigurator configurator = new CodegenConfigurator().setGeneratorName("asciidoc") + .setInputSpec("src/test/resources/3_0/ping.yaml").setOutputDir(output.getAbsolutePath()) + .addAdditionalProperty(AsciidocDocumentationCodegen.SNIPPET_DIR, "MY-SNIPPET-DIR") + .addAdditionalProperty(AsciidocDocumentationCodegen.SPEC_DIR, "MY-SPEC-DIR"); + + final ClientOptInput clientOptInput = configurator.toClientOptInput(); + DefaultGenerator generator = new DefaultGenerator(); + generator.setGenerateMetadata(false); + List generatedFiles = generator.opts(clientOptInput).generate(); + TestUtils.ensureContainsFile(generatedFiles, output, "index.adoc"); + } + + @Test + public void testGenerateIndexAsciidocMarkupContent() throws Exception { + final File output = Files.createTempDirectory("test").toFile(); + output.mkdirs(); + output.deleteOnExit(); + + final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/ping.yaml"); + CodegenConfig codegenConfig = new AsciidocDocumentationCodegen(); + codegenConfig.setOutputDir(output.getAbsolutePath()); + ClientOptInput clientOptInput = new ClientOptInput().openAPI(openAPI).config(codegenConfig); + + DefaultGenerator generator = new DefaultGenerator(); + List files = generator.opts(clientOptInput).generate(); + boolean markupFileGenerated = false; + for (File file : files) { + if (file.getName().equals("index.adoc")) { + markupFileGenerated = true; + String markupContent = FileUtils.readFileToString(file, StandardCharsets.UTF_8); + // check on some basic asciidoc markup content + Assert.assertTrue(markupContent.contains("= ping test"), + "expected = header in: " + markupContent.substring(0, 50)); + Assert.assertTrue(markupContent.contains(":toc: "), + "expected = :toc: " + markupContent.substring(0, 50)); + } + } + Assert.assertTrue(markupFileGenerated, "Default api file is not generated!"); + } + + @Test + public void testAdditionalDirectoriesGeneratedIntoHeaderAttributes() throws Exception { + File output = Files.createTempDirectory("test").toFile(); + + LOGGER.info("test: generating sample markup " + output.getAbsolutePath()); + + Map props = new TreeMap(); + props.put("specDir", "spec"); + + final CodegenConfigurator configurator = new CodegenConfigurator().setGeneratorName("asciidoc") + .setInputSpec("src/test/resources/3_0/ping.yaml").setOutputDir(output.getAbsolutePath()) + .addAdditionalProperty(AsciidocDocumentationCodegen.SPEC_DIR, "SPEC-DIR") + .addAdditionalProperty(AsciidocDocumentationCodegen.SNIPPET_DIR, "MY/SNIPPET/DIR"); + + DefaultGenerator generator = new DefaultGenerator(); + List files = generator.opts(configurator.toClientOptInput()).generate(); + boolean markupFileGenerated = false; + for (File file : files) { + if (file.getName().equals("index.adoc")) { + markupFileGenerated = true; + String markupContent = FileUtils.readFileToString(file, StandardCharsets.UTF_8); + Assert.assertTrue(markupContent.contains(":specDir: SPEC-DIR"), + "expected :specDir: in: " + markupContent.substring(0, 250)); + Assert.assertTrue(markupContent.contains(":snippetDir: MY/SNIPPET/DIR"), + "expected :snippetDir: in: " + markupContent.substring(0, 250)); + } + } + Assert.assertTrue(markupFileGenerated, "index.adoc is not generated!"); + + } + + + @Test + public void testHeaderAttributesFlagRemovesAttributesFromMarkupHeaderSection() throws Exception { + File output = Files.createTempDirectory("test").toFile(); + + LOGGER.info("test: generating sample markup " + output.getAbsolutePath()); + + Map props = new TreeMap(); + props.put("specDir", "spec"); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("asciidoc") + .setInputSpec("src/test/resources/3_0/ping.yaml") + .setOutputDir(output.getAbsolutePath()) + .addAdditionalProperty(AsciidocDocumentationCodegen.HEADER_ATTRIBUTES_FLAG, "false") // option avoids generation of attributes + .addAdditionalProperty(AsciidocDocumentationCodegen.SPEC_DIR, "SPEC-DIR") + .addAdditionalProperty(AsciidocDocumentationCodegen.SNIPPET_DIR, "MY/SNIPPET/DIR"); + + DefaultGenerator generator = new DefaultGenerator(); + boolean markupFileGenerated = false; + List files = generator.opts(configurator.toClientOptInput()).generate(); + for (File file : files) { + if (file.getName().equals("index.adoc")) { + markupFileGenerated = true; + String markupContent = FileUtils.readFileToString(file, StandardCharsets.UTF_8); + Assert.assertFalse(markupContent.contains(":specDir: SPEC-DIR"), + "not expected :specDir: in: " + markupContent.substring(0, 250)); + Assert.assertFalse(markupContent.contains(":snippetDir: MY/SNIPPET/DIR"), + "not expected :snippetDir: in: " + markupContent.substring(0, 250)); + Assert.assertFalse(markupContent.contains(":toc:"), + "not expected :toc: in: " + markupContent.substring(0, 250)); // typical attributes not found in markup. + } + } + Assert.assertTrue(markupFileGenerated, "index.adoc is not generated!"); + } + +} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/asciidoc/LinkMarkupFilterTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/asciidoc/LinkMarkupFilterTest.java index 3d04eec3110..9cc8c991555 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/asciidoc/LinkMarkupFilterTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/asciidoc/LinkMarkupFilterTest.java @@ -1,47 +1,47 @@ -package org.openapitools.codegen.asciidoc; - -import java.io.File; -import java.io.IOException; -import java.util.Map; - -import org.mockito.MockitoAnnotations; -import org.openapitools.codegen.languages.AsciidocDocumentationCodegen; -import org.openapitools.codegen.templating.mustache.LambdaTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import org.testng.Assert; - -public class LinkMarkupFilterTest extends LambdaTest { - - @BeforeMethod - public void setup() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testLinkMarkupFilterDoesNotLinkMissingFile() { - - final AsciidocDocumentationCodegen generator = new AsciidocDocumentationCodegen(); - final Map ctx = context("link", generator.new LinkMarkupLambda("DOES_NOT_EXIST")); - - final String result = execute("{{#link}}not.an.existing.file.adoc{{/link}}", ctx); - Assert.assertTrue(result.contains("// file not found, no"), "unexpected filtered: " + result); - } - - @Test - public void testLinkMarkupFilterLinksFoundFileOk() throws IOException { - - File tempFile = File.createTempFile("LinkMarkupFilterTestDummyfile", ".adoc"); - tempFile.deleteOnExit(); - - final AsciidocDocumentationCodegen generator = new AsciidocDocumentationCodegen(); - final Map ctx = context("linkIntoMarkup", generator.new LinkMarkupLambda(tempFile.getParent())); - - final String result = execute("{{#linkIntoMarkup}}my link text, " + tempFile.getName() + "{{/linkIntoMarkup}}", - ctx); - Assert.assertTrue(result.contains("link:"), "unexpected filtered: " + result); - Assert.assertTrue(result.contains(tempFile.getName() + "[]"), "unexpected filtered: " + result); - } - -} +package org.openapitools.codegen.asciidoc; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +import org.mockito.MockitoAnnotations; +import org.openapitools.codegen.languages.AsciidocDocumentationCodegen; +import org.openapitools.codegen.templating.mustache.LambdaTest; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import org.testng.Assert; + +public class LinkMarkupFilterTest extends LambdaTest { + + @BeforeMethod + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testLinkMarkupFilterDoesNotLinkMissingFile() { + + final AsciidocDocumentationCodegen generator = new AsciidocDocumentationCodegen(); + final Map ctx = context("link", generator.new LinkMarkupLambda("DOES_NOT_EXIST")); + + final String result = execute("{{#link}}not.an.existing.file.adoc{{/link}}", ctx); + Assert.assertTrue(result.contains("// file not found, no"), "unexpected filtered: " + result); + } + + @Test + public void testLinkMarkupFilterLinksFoundFileOk() throws IOException { + + File tempFile = File.createTempFile("LinkMarkupFilterTestDummyfile", ".adoc"); + tempFile.deleteOnExit(); + + final AsciidocDocumentationCodegen generator = new AsciidocDocumentationCodegen(); + final Map ctx = context("linkIntoMarkup", generator.new LinkMarkupLambda(tempFile.getParent())); + + final String result = execute("{{#linkIntoMarkup}}my link text, " + tempFile.getName() + "{{/linkIntoMarkup}}", + ctx); + Assert.assertTrue(result.contains("link:"), "unexpected filtered: " + result); + Assert.assertTrue(result.contains(tempFile.getName() + "[]"), "unexpected filtered: " + result); + } + +} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/mysql/MysqlSchemaCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/mysql/MysqlSchemaCodegenTest.java index e1917fd583a..25951faacfb 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/mysql/MysqlSchemaCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/mysql/MysqlSchemaCodegenTest.java @@ -1,314 +1,314 @@ -/* - * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openapitools.codegen.mysql; - -import org.openapitools.codegen.languages.MysqlSchemaCodegen; -import org.testng.Assert; -import org.testng.annotations.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Set; - -public class MysqlSchemaCodegenTest { - - @Test - public void testGetMysqlMatchedIntegerDataType() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(null, null, null), "INT"); - - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(-128L, 127L, false), "TINYINT"); - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(0L, 255L, true), "TINYINT"); - - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(500L, 100L, null), "SMALLINT"); - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(500L, 100L, true), "SMALLINT"); - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(500L, 100L, false), "SMALLINT"); - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(-32768L, 32767L, false), "SMALLINT"); - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(0L, 65535L, true), "SMALLINT"); - - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(-8388608L, 8388607L, false), "MEDIUMINT"); - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(0L, 16777215L, true), "MEDIUMINT"); - - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(-2147483648L, 2147483647L, false), "INT"); - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(Long.parseLong(String.valueOf(Integer.MIN_VALUE)), Long.parseLong(String.valueOf(Integer.MAX_VALUE)), false), "INT"); - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(0L, 4294967295L, true), "INT"); - - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(-2147483649L, 2147483648L, false), "BIGINT"); - Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(0L, 4294967296L, true), "BIGINT"); - } - - @Test - public void testGetMysqlMatchedStringDataType() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(6, 6), "CHAR"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(0, 0), "CHAR"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(255, 255), "CHAR"); - - Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 100), "VARCHAR"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 255), "VARCHAR"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(50, 255), "VARCHAR"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, 20), "VARCHAR"); - - Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, null), "TEXT"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, null), "TEXT"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(255, null), "TEXT"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 256), "TEXT"); - - Assert.assertSame(codegen.getMysqlMatchedStringDataType(16777215, null), "MEDIUMTEXT"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(16777215, 100), "MEDIUMTEXT"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 16777215), "MEDIUMTEXT"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, 16777215), "MEDIUMTEXT"); - - Assert.assertSame(codegen.getMysqlMatchedStringDataType(16777216, null), "LONGTEXT"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 16777216), "LONGTEXT"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(16777216, 16777216), "LONGTEXT"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, 16777216), "LONGTEXT"); - Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, Integer.MAX_VALUE), "LONGTEXT"); - } - - @Test - public void testToCodegenMysqlDataTypeArgument() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - String strArgument = "HelloWorld"; - HashMap strProp = codegen.toCodegenMysqlDataTypeArgument(strArgument, true); - Assert.assertTrue((Boolean) strProp.get("isString")); - Assert.assertTrue((Boolean) strProp.get("hasMore")); - Assert.assertFalse((Boolean) strProp.get("isFloat")); - Assert.assertFalse((Boolean) strProp.get("isInteger")); - Assert.assertFalse((Boolean) strProp.get("isNumeric")); - Assert.assertSame((String) strProp.get("argumentValue"), strArgument); - - Integer intArgument = 10; - HashMap intProp = codegen.toCodegenMysqlDataTypeArgument(intArgument, true); - Assert.assertFalse((Boolean) intProp.get("isString")); - Assert.assertTrue((Boolean) intProp.get("hasMore")); - Assert.assertFalse((Boolean) intProp.get("isFloat")); - Assert.assertTrue((Boolean) intProp.get("isInteger")); - Assert.assertTrue((Boolean) intProp.get("isNumeric")); - Assert.assertSame((Integer) intProp.get("argumentValue"), intArgument); - - Double floatArgument = 3.14; - HashMap floatProp = codegen.toCodegenMysqlDataTypeArgument(floatArgument, false); - Assert.assertFalse((Boolean) floatProp.get("isString")); - Assert.assertFalse((Boolean) floatProp.get("hasMore")); - Assert.assertTrue((Boolean) floatProp.get("isFloat")); - Assert.assertFalse((Boolean) floatProp.get("isInteger")); - Assert.assertTrue((Boolean) floatProp.get("isNumeric")); - Assert.assertSame((Double) floatProp.get("argumentValue"), floatArgument); - } - - @Test - public void testToCodegenMysqlDataTypeDefault() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - HashMap defaultMap = null; - ArrayList intFixture = new ArrayList(Arrays.asList( - "TINYINT", "SmallInt", "Mediumint", "INT", "bigint" - )); - for(String intType : intFixture) { - defaultMap = codegen.toCodegenMysqlDataTypeDefault("150", intType); - Assert.assertTrue((Boolean) defaultMap.get("isNumeric")); - Assert.assertFalse((Boolean) defaultMap.get("isString")); - Assert.assertFalse((Boolean) defaultMap.get("isKeyword")); - Assert.assertSame(defaultMap.get("defaultValue"), "150"); - } - defaultMap = codegen.toCodegenMysqlDataTypeDefault("SERIAL DEFAULT VALUE", "TINYINT"); - Assert.assertFalse((Boolean) defaultMap.get("isNumeric")); - Assert.assertFalse((Boolean) defaultMap.get("isString")); - Assert.assertTrue((Boolean) defaultMap.get("isKeyword")); - Assert.assertSame(defaultMap.get("defaultValue"), "SERIAL DEFAULT VALUE"); - - ArrayList dateFixture = new ArrayList(Arrays.asList( - "Timestamp", "DateTime" - )); - for(String dateType : dateFixture) { - defaultMap = codegen.toCodegenMysqlDataTypeDefault("2018-08-12", dateType); - Assert.assertFalse((Boolean) defaultMap.get("isNumeric")); - Assert.assertTrue((Boolean) defaultMap.get("isString")); - Assert.assertFalse((Boolean) defaultMap.get("isKeyword")); - Assert.assertSame(defaultMap.get("defaultValue"), "2018-08-12"); - } - defaultMap = codegen.toCodegenMysqlDataTypeDefault("CURRENT_TIMESTAMP", "Timestamp"); - Assert.assertFalse((Boolean) defaultMap.get("isNumeric")); - Assert.assertFalse((Boolean) defaultMap.get("isString")); - Assert.assertTrue((Boolean) defaultMap.get("isKeyword")); - Assert.assertSame(defaultMap.get("defaultValue"), "CURRENT_TIMESTAMP"); - - ArrayList restFixture = new ArrayList(Arrays.asList( - "VARCHAR", "CHAR", "ENUM", "UNKNOWN" - )); - for(String restType : restFixture) { - defaultMap = codegen.toCodegenMysqlDataTypeDefault("sometext", restType); - Assert.assertFalse((Boolean) defaultMap.get("isNumeric")); - Assert.assertTrue((Boolean) defaultMap.get("isString")); - Assert.assertFalse((Boolean) defaultMap.get("isKeyword")); - Assert.assertSame(defaultMap.get("defaultValue"), "sometext"); - } - } - - @Test(expectedExceptions = RuntimeException.class) - public void testToCodegenMysqlDataTypeDefaultWithExceptionalColumnType() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - HashMap defaultMap = null; - ArrayList specialFixture = new ArrayList(Arrays.asList( - "TINYBLOB", "Blob", "MEDIUMBLOB", "LONGBLOB", "TINYTEXT", "TEXT", "MEDIUMTEXT", "LONGTEXT", "GEOMETRY", "JSON" - )); - for(String specialType : specialFixture) { - defaultMap = codegen.toCodegenMysqlDataTypeDefault("2018-08-12", specialType); - Assert.assertNull(defaultMap); - } - } - - @Test - public void testIsMysqlDataType() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - ArrayList trueFixture = new ArrayList(Arrays.asList( - "INTEGER", "integer", "Integer", "DATETIME", "datetime", "DateTime", "VARCHAR", "varchar", "VarChar", "POINT", "Point", "point", "JSON", "json", "Json" - )); - ArrayList falseFixture = new ArrayList(Arrays.asList( - "unknown", "HashMap", "HASHMAP", "hashmap" - )); - for(String trueValue : trueFixture) { - Assert.assertTrue(codegen.isMysqlDataType(trueValue), "'" + trueValue + "' isn't MySQL data type"); - } - for(String falseValue : falseFixture) { - Assert.assertFalse(codegen.isMysqlDataType(falseValue), "'" + falseValue + "' is MySQL data type"); - } - } - - @Test - public void testToMysqlIdentifier() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - Assert.assertEquals(codegen.toMysqlIdentifier("table_name", "tbl_", ""), "table_name"); - Assert.assertEquals(codegen.toMysqlIdentifier("table_name ", "tbl_", ""), "table_name"); - Assert.assertEquals(codegen.toMysqlIdentifier("12345678", "tbl_", ""), "tbl_12345678"); - } - - @Test(expectedExceptions = RuntimeException.class) - public void testToMysqlIdentifierWithEmptyString() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - codegen.toMysqlIdentifier(" ", "tbl_", ""); - } - - @Test - public void testEscapeMysqlUnquotedIdentifier() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - Assert.assertEquals(codegen.escapeMysqlUnquotedIdentifier("table1Z$_"), "table1Z$_"); - Assert.assertEquals(codegen.escapeMysqlUnquotedIdentifier("table1Z$_!#%~&?()*+-./"), "table1Z$_"); - Assert.assertEquals(codegen.escapeMysqlUnquotedIdentifier("table1Z$_русскийтекст"), "table1Z$_русскийтекст"); - Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table𐀀"), "table"); - Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table_name!'()�"), "table_name!'()�"); - Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table_name𐌅𐌌"), "table_name"); - } - - @Test - public void testEscapeMysqlQuotedIdentifier() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table"), "table"); - Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table𐀀"), "table"); - Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table_name!'()�"), "table_name!'()�"); - Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table_name𐌅𐌌"), "table_name"); - } - - @Test - public void testIsReservedWord() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - Set reservedWords = codegen.reservedWords(); - ArrayList trueFixture = new ArrayList(Arrays.asList( - "accessible", "asc", "between", "blob", "change", "column", "day_hour", "distinct", "enclosed", "except", "explain", "float", "for", "function", "grant", "grouping", "high_priority", "groups", "hour_minute", "insensitive", "interval", "json_table", "keys", "kill", "leave", "left", "mediumblob", "modifies", "not", "null", "numeric", "optimize", "outer", "precision", "primary", "references", "replace", "select", "sql", "then", "tinytext", "unique", "unlock", "varchar", "virtual", "when", "where", "xor", "year_month", "zerofill" - )); - ArrayList falseFixture = new ArrayList(Arrays.asList( - "after", "boolean", "charset", "cpu", "current", "delay_key_write", "end", "format", "global", "host", "install", "json", "key_block_size", "local", "max_size", "none", "offset", "partial", "quarter", "relay", "second", "status", "timestamp", "until", "variables", "without", "xml", "year" - )); - for(String trueValue : trueFixture) { - Assert.assertTrue(reservedWords.contains(trueValue), "'" + trueValue + "' isn't MySQL reserved word"); - } - for(String falseValue : falseFixture) { - Assert.assertFalse(reservedWords.contains(falseValue), "'" + falseValue + "' is MySQL reserved word"); - } - } - - @Test - public void testSetDefaultDatabaseName() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - codegen.setDefaultDatabaseName("valid_db_name"); - Assert.assertSame(codegen.getDefaultDatabaseName(), "valid_db_name"); - codegen.setDefaultDatabaseName("12345"); - Assert.assertNotSame(codegen.getDefaultDatabaseName(), "12345"); - } - - @Test - public void testGetDefaultDatabaseName() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - Assert.assertSame(codegen.getDefaultDatabaseName(), ""); - } - - @Test - public void testSetJsonDataTypeEnabled() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - codegen.setJsonDataTypeEnabled(true); - Assert.assertTrue(codegen.getJsonDataTypeEnabled()); - codegen.setJsonDataTypeEnabled(false); - Assert.assertFalse(codegen.getJsonDataTypeEnabled()); - } - - @Test - public void testGetJsonDataTypeEnabled() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - Assert.assertTrue(codegen.getJsonDataTypeEnabled()); - codegen.setJsonDataTypeEnabled(false); - Assert.assertFalse(codegen.getJsonDataTypeEnabled()); - } - - @Test - public void testSetNamedParametersEnabled() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - codegen.setNamedParametersEnabled(true); - Assert.assertTrue(codegen.getNamedParametersEnabled()); - codegen.setNamedParametersEnabled(false); - Assert.assertFalse(codegen.getNamedParametersEnabled()); - } - - @Test - public void testGetNamedParametersEnabled() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - Assert.assertFalse(codegen.getNamedParametersEnabled()); - codegen.setNamedParametersEnabled(true); - Assert.assertTrue(codegen.getNamedParametersEnabled()); - } - - @Test - public void testSetIdentifierNamingConvention() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - Assert.assertSame("original", codegen.getIdentifierNamingConvention()); - codegen.setIdentifierNamingConvention("invalidValue"); - Assert.assertSame("original", codegen.getIdentifierNamingConvention()); - codegen.setIdentifierNamingConvention("snake_case"); - Assert.assertSame("snake_case", codegen.getIdentifierNamingConvention()); - codegen.setIdentifierNamingConvention("anotherInvalid"); - Assert.assertSame("snake_case", codegen.getIdentifierNamingConvention()); - } - - @Test - public void testGetIdentifierNamingConvention() { - final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); - Assert.assertSame("original", codegen.getIdentifierNamingConvention()); - codegen.setIdentifierNamingConvention("snake_case"); - Assert.assertSame("snake_case", codegen.getIdentifierNamingConvention()); - } - -} +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.codegen.mysql; + +import org.openapitools.codegen.languages.MysqlSchemaCodegen; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Set; + +public class MysqlSchemaCodegenTest { + + @Test + public void testGetMysqlMatchedIntegerDataType() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(null, null, null), "INT"); + + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(-128L, 127L, false), "TINYINT"); + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(0L, 255L, true), "TINYINT"); + + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(500L, 100L, null), "SMALLINT"); + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(500L, 100L, true), "SMALLINT"); + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(500L, 100L, false), "SMALLINT"); + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(-32768L, 32767L, false), "SMALLINT"); + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(0L, 65535L, true), "SMALLINT"); + + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(-8388608L, 8388607L, false), "MEDIUMINT"); + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(0L, 16777215L, true), "MEDIUMINT"); + + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(-2147483648L, 2147483647L, false), "INT"); + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(Long.parseLong(String.valueOf(Integer.MIN_VALUE)), Long.parseLong(String.valueOf(Integer.MAX_VALUE)), false), "INT"); + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(0L, 4294967295L, true), "INT"); + + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(-2147483649L, 2147483648L, false), "BIGINT"); + Assert.assertSame(codegen.getMysqlMatchedIntegerDataType(0L, 4294967296L, true), "BIGINT"); + } + + @Test + public void testGetMysqlMatchedStringDataType() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(6, 6), "CHAR"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(0, 0), "CHAR"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(255, 255), "CHAR"); + + Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 100), "VARCHAR"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 255), "VARCHAR"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(50, 255), "VARCHAR"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, 20), "VARCHAR"); + + Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, null), "TEXT"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, null), "TEXT"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(255, null), "TEXT"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 256), "TEXT"); + + Assert.assertSame(codegen.getMysqlMatchedStringDataType(16777215, null), "MEDIUMTEXT"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(16777215, 100), "MEDIUMTEXT"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 16777215), "MEDIUMTEXT"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, 16777215), "MEDIUMTEXT"); + + Assert.assertSame(codegen.getMysqlMatchedStringDataType(16777216, null), "LONGTEXT"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(null, 16777216), "LONGTEXT"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(16777216, 16777216), "LONGTEXT"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, 16777216), "LONGTEXT"); + Assert.assertSame(codegen.getMysqlMatchedStringDataType(100, Integer.MAX_VALUE), "LONGTEXT"); + } + + @Test + public void testToCodegenMysqlDataTypeArgument() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + String strArgument = "HelloWorld"; + HashMap strProp = codegen.toCodegenMysqlDataTypeArgument(strArgument, true); + Assert.assertTrue((Boolean) strProp.get("isString")); + Assert.assertTrue((Boolean) strProp.get("hasMore")); + Assert.assertFalse((Boolean) strProp.get("isFloat")); + Assert.assertFalse((Boolean) strProp.get("isInteger")); + Assert.assertFalse((Boolean) strProp.get("isNumeric")); + Assert.assertSame((String) strProp.get("argumentValue"), strArgument); + + Integer intArgument = 10; + HashMap intProp = codegen.toCodegenMysqlDataTypeArgument(intArgument, true); + Assert.assertFalse((Boolean) intProp.get("isString")); + Assert.assertTrue((Boolean) intProp.get("hasMore")); + Assert.assertFalse((Boolean) intProp.get("isFloat")); + Assert.assertTrue((Boolean) intProp.get("isInteger")); + Assert.assertTrue((Boolean) intProp.get("isNumeric")); + Assert.assertSame((Integer) intProp.get("argumentValue"), intArgument); + + Double floatArgument = 3.14; + HashMap floatProp = codegen.toCodegenMysqlDataTypeArgument(floatArgument, false); + Assert.assertFalse((Boolean) floatProp.get("isString")); + Assert.assertFalse((Boolean) floatProp.get("hasMore")); + Assert.assertTrue((Boolean) floatProp.get("isFloat")); + Assert.assertFalse((Boolean) floatProp.get("isInteger")); + Assert.assertTrue((Boolean) floatProp.get("isNumeric")); + Assert.assertSame((Double) floatProp.get("argumentValue"), floatArgument); + } + + @Test + public void testToCodegenMysqlDataTypeDefault() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + HashMap defaultMap = null; + ArrayList intFixture = new ArrayList(Arrays.asList( + "TINYINT", "SmallInt", "Mediumint", "INT", "bigint" + )); + for(String intType : intFixture) { + defaultMap = codegen.toCodegenMysqlDataTypeDefault("150", intType); + Assert.assertTrue((Boolean) defaultMap.get("isNumeric")); + Assert.assertFalse((Boolean) defaultMap.get("isString")); + Assert.assertFalse((Boolean) defaultMap.get("isKeyword")); + Assert.assertSame(defaultMap.get("defaultValue"), "150"); + } + defaultMap = codegen.toCodegenMysqlDataTypeDefault("SERIAL DEFAULT VALUE", "TINYINT"); + Assert.assertFalse((Boolean) defaultMap.get("isNumeric")); + Assert.assertFalse((Boolean) defaultMap.get("isString")); + Assert.assertTrue((Boolean) defaultMap.get("isKeyword")); + Assert.assertSame(defaultMap.get("defaultValue"), "SERIAL DEFAULT VALUE"); + + ArrayList dateFixture = new ArrayList(Arrays.asList( + "Timestamp", "DateTime" + )); + for(String dateType : dateFixture) { + defaultMap = codegen.toCodegenMysqlDataTypeDefault("2018-08-12", dateType); + Assert.assertFalse((Boolean) defaultMap.get("isNumeric")); + Assert.assertTrue((Boolean) defaultMap.get("isString")); + Assert.assertFalse((Boolean) defaultMap.get("isKeyword")); + Assert.assertSame(defaultMap.get("defaultValue"), "2018-08-12"); + } + defaultMap = codegen.toCodegenMysqlDataTypeDefault("CURRENT_TIMESTAMP", "Timestamp"); + Assert.assertFalse((Boolean) defaultMap.get("isNumeric")); + Assert.assertFalse((Boolean) defaultMap.get("isString")); + Assert.assertTrue((Boolean) defaultMap.get("isKeyword")); + Assert.assertSame(defaultMap.get("defaultValue"), "CURRENT_TIMESTAMP"); + + ArrayList restFixture = new ArrayList(Arrays.asList( + "VARCHAR", "CHAR", "ENUM", "UNKNOWN" + )); + for(String restType : restFixture) { + defaultMap = codegen.toCodegenMysqlDataTypeDefault("sometext", restType); + Assert.assertFalse((Boolean) defaultMap.get("isNumeric")); + Assert.assertTrue((Boolean) defaultMap.get("isString")); + Assert.assertFalse((Boolean) defaultMap.get("isKeyword")); + Assert.assertSame(defaultMap.get("defaultValue"), "sometext"); + } + } + + @Test(expectedExceptions = RuntimeException.class) + public void testToCodegenMysqlDataTypeDefaultWithExceptionalColumnType() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + HashMap defaultMap = null; + ArrayList specialFixture = new ArrayList(Arrays.asList( + "TINYBLOB", "Blob", "MEDIUMBLOB", "LONGBLOB", "TINYTEXT", "TEXT", "MEDIUMTEXT", "LONGTEXT", "GEOMETRY", "JSON" + )); + for(String specialType : specialFixture) { + defaultMap = codegen.toCodegenMysqlDataTypeDefault("2018-08-12", specialType); + Assert.assertNull(defaultMap); + } + } + + @Test + public void testIsMysqlDataType() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + ArrayList trueFixture = new ArrayList(Arrays.asList( + "INTEGER", "integer", "Integer", "DATETIME", "datetime", "DateTime", "VARCHAR", "varchar", "VarChar", "POINT", "Point", "point", "JSON", "json", "Json" + )); + ArrayList falseFixture = new ArrayList(Arrays.asList( + "unknown", "HashMap", "HASHMAP", "hashmap" + )); + for(String trueValue : trueFixture) { + Assert.assertTrue(codegen.isMysqlDataType(trueValue), "'" + trueValue + "' isn't MySQL data type"); + } + for(String falseValue : falseFixture) { + Assert.assertFalse(codegen.isMysqlDataType(falseValue), "'" + falseValue + "' is MySQL data type"); + } + } + + @Test + public void testToMysqlIdentifier() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + Assert.assertEquals(codegen.toMysqlIdentifier("table_name", "tbl_", ""), "table_name"); + Assert.assertEquals(codegen.toMysqlIdentifier("table_name ", "tbl_", ""), "table_name"); + Assert.assertEquals(codegen.toMysqlIdentifier("12345678", "tbl_", ""), "tbl_12345678"); + } + + @Test(expectedExceptions = RuntimeException.class) + public void testToMysqlIdentifierWithEmptyString() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + codegen.toMysqlIdentifier(" ", "tbl_", ""); + } + + @Test + public void testEscapeMysqlUnquotedIdentifier() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + Assert.assertEquals(codegen.escapeMysqlUnquotedIdentifier("table1Z$_"), "table1Z$_"); + Assert.assertEquals(codegen.escapeMysqlUnquotedIdentifier("table1Z$_!#%~&?()*+-./"), "table1Z$_"); + Assert.assertEquals(codegen.escapeMysqlUnquotedIdentifier("table1Z$_русскийтекст"), "table1Z$_русскийтекст"); + Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table𐀀"), "table"); + Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table_name!'()�"), "table_name!'()�"); + Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table_name𐌅𐌌"), "table_name"); + } + + @Test + public void testEscapeMysqlQuotedIdentifier() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table"), "table"); + Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table𐀀"), "table"); + Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table_name!'()�"), "table_name!'()�"); + Assert.assertEquals(codegen.escapeMysqlQuotedIdentifier("table_name𐌅𐌌"), "table_name"); + } + + @Test + public void testIsReservedWord() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + Set reservedWords = codegen.reservedWords(); + ArrayList trueFixture = new ArrayList(Arrays.asList( + "accessible", "asc", "between", "blob", "change", "column", "day_hour", "distinct", "enclosed", "except", "explain", "float", "for", "function", "grant", "grouping", "high_priority", "groups", "hour_minute", "insensitive", "interval", "json_table", "keys", "kill", "leave", "left", "mediumblob", "modifies", "not", "null", "numeric", "optimize", "outer", "precision", "primary", "references", "replace", "select", "sql", "then", "tinytext", "unique", "unlock", "varchar", "virtual", "when", "where", "xor", "year_month", "zerofill" + )); + ArrayList falseFixture = new ArrayList(Arrays.asList( + "after", "boolean", "charset", "cpu", "current", "delay_key_write", "end", "format", "global", "host", "install", "json", "key_block_size", "local", "max_size", "none", "offset", "partial", "quarter", "relay", "second", "status", "timestamp", "until", "variables", "without", "xml", "year" + )); + for(String trueValue : trueFixture) { + Assert.assertTrue(reservedWords.contains(trueValue), "'" + trueValue + "' isn't MySQL reserved word"); + } + for(String falseValue : falseFixture) { + Assert.assertFalse(reservedWords.contains(falseValue), "'" + falseValue + "' is MySQL reserved word"); + } + } + + @Test + public void testSetDefaultDatabaseName() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + codegen.setDefaultDatabaseName("valid_db_name"); + Assert.assertSame(codegen.getDefaultDatabaseName(), "valid_db_name"); + codegen.setDefaultDatabaseName("12345"); + Assert.assertNotSame(codegen.getDefaultDatabaseName(), "12345"); + } + + @Test + public void testGetDefaultDatabaseName() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + Assert.assertSame(codegen.getDefaultDatabaseName(), ""); + } + + @Test + public void testSetJsonDataTypeEnabled() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + codegen.setJsonDataTypeEnabled(true); + Assert.assertTrue(codegen.getJsonDataTypeEnabled()); + codegen.setJsonDataTypeEnabled(false); + Assert.assertFalse(codegen.getJsonDataTypeEnabled()); + } + + @Test + public void testGetJsonDataTypeEnabled() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + Assert.assertTrue(codegen.getJsonDataTypeEnabled()); + codegen.setJsonDataTypeEnabled(false); + Assert.assertFalse(codegen.getJsonDataTypeEnabled()); + } + + @Test + public void testSetNamedParametersEnabled() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + codegen.setNamedParametersEnabled(true); + Assert.assertTrue(codegen.getNamedParametersEnabled()); + codegen.setNamedParametersEnabled(false); + Assert.assertFalse(codegen.getNamedParametersEnabled()); + } + + @Test + public void testGetNamedParametersEnabled() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + Assert.assertFalse(codegen.getNamedParametersEnabled()); + codegen.setNamedParametersEnabled(true); + Assert.assertTrue(codegen.getNamedParametersEnabled()); + } + + @Test + public void testSetIdentifierNamingConvention() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + Assert.assertSame("original", codegen.getIdentifierNamingConvention()); + codegen.setIdentifierNamingConvention("invalidValue"); + Assert.assertSame("original", codegen.getIdentifierNamingConvention()); + codegen.setIdentifierNamingConvention("snake_case"); + Assert.assertSame("snake_case", codegen.getIdentifierNamingConvention()); + codegen.setIdentifierNamingConvention("anotherInvalid"); + Assert.assertSame("snake_case", codegen.getIdentifierNamingConvention()); + } + + @Test + public void testGetIdentifierNamingConvention() { + final MysqlSchemaCodegen codegen = new MysqlSchemaCodegen(); + Assert.assertSame("original", codegen.getIdentifierNamingConvention()); + codegen.setIdentifierNamingConvention("snake_case"); + Assert.assertSame("snake_case", codegen.getIdentifierNamingConvention()); + } + +} diff --git a/modules/openapi-generator/src/test/resources/3_0/asciidoc/api-docs.json b/modules/openapi-generator/src/test/resources/3_0/asciidoc/api-docs.json index 4f1c22adf5d..8f128626937 100644 --- a/modules/openapi-generator/src/test/resources/3_0/asciidoc/api-docs.json +++ b/modules/openapi-generator/src/test/resources/3_0/asciidoc/api-docs.json @@ -1,1416 +1,1416 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "time@work rest api", - "description": "internal rest api, used by time@work angular client", - "contact": { - "name": "man@home", - "url": "https://gitlab.com/spare-time-demos/timeatwork", - "email": "man.at.home@do-not-use-this-mail.com" - }, - "license": { - "name": "Apache 2.0", - "url": "https://www.apache.org/licenses/LICENSE-2.0.txt" - }, - "version": "0.1" - }, - "externalDocs": { - "description": "specs", - "url": "https://gitlab.com/spare-time-demos/timeatwork/tree/master/docs/src/main/docs/features" - }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "tags": [ - { - "name": "ui-admin", - "description": "ui: admin and team lead api calls" - }, - { - "name": "ui-user", - "description": "ui: user api calls" - }, - { - "name": "security", - "description": "login" - }, - { - "name": "admin", - "description": "admin api, internal use" - } - ], - "paths": { - "/rest/admin/info": { - "get": { - "tags": [ - "admin" - ], - "summary": "(dummy) application info endpoint.", - "operationId": "info", - "responses": { - "200": { - "description": "default response", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - } - } - } - } - }, - "/rest/admin/job/usersync": { - "get": { - "tags": [ - "admin" - ], - "summary": "start background job: usersync", - "operationId": "startuserSync", - "responses": { - "200": { - "description": "default response", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - } - } - } - } - }, - "/authentication": { - "post": { - "tags": [ - "security" - ], - "summary": "login with username and password, getting an jwt token on successful.", - "operationId": "login", - "requestBody": { - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/AuthenticationRequest" - } - } - } - }, - "responses": { - "200": { - "description": "default response", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/AuthenticationResult" - } - } - } - } - } - } - }, - "/rest/project/": { - "get": { - "tags": [ - "ui-admin" - ], - "summary": "retrieving all visible projects for current user.", - "operationId": "getProjects", - "responses": { - "200": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/CProject" - } - } - } - } - } - } - }, - "post": { - "tags": [ - "ui-admin" - ], - "summary": "create a new project.", - "operationId": "createProject", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CProject" - } - } - } - }, - "responses": { - "201": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CProject" - } - } - } - } - } - } - }, - "/rest/project/{projectId}": { - "get": { - "tags": [ - "ui-admin" - ], - "summary": "retrieving a specific visible projects for current user.", - "operationId": "getProject", - "parameters": [ - { - "name": "projectId", - "in": "path", - "description": "unique project id to find", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - }, - "example": "0185" - } - ], - "responses": { - "200": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CProject" - } - } - } - } - } - }, - "put": { - "tags": [ - "ui-admin" - ], - "summary": "change an existing project.", - "operationId": "changeProject", - "parameters": [ - { - "name": "projectId", - "in": "path", - "description": "unique project id to change", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - }, - "example": "0815" - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CProject" - } - } - } - }, - "responses": { - "200": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CProject" - } - } - } - } - } - } - }, - "/rest/project/{projectId}/task": { - "get": { - "tags": [ - "ui-admin" - ], - "summary": "retrieving tasks for a specific project.", - "operationId": "getProjectTasks", - "parameters": [ - { - "name": "projectId", - "in": "path", - "description": "project id to find tasks for", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - }, - "example": "0815" - } - ], - "responses": { - "200": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/CTask" - } - } - } - } - } - } - }, - "post": { - "tags": [ - "ui-admin" - ], - "summary": "create a new task for an existing project", - "operationId": "createTaskForProject", - "parameters": [ - { - "name": "projectId", - "in": "path", - "description": "project id for task to change", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - }, - "example": "0815" - } - ], - "requestBody": { - "description": "new task data", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CTask" - } - } - }, - "required": false - }, - "responses": { - "201": { - "description": "task created", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CTask" - } - } - } - }, - "403": { - "description": "not authorized as project lead or admin", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CTask" - } - } - } - }, - "404": { - "description": "project not found", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ResponseStatusException" - } - } - } - } - } - } - }, - "/rest/task/{taskId}/assignment": { - "get": { - "tags": [ - "ui-admin" - ], - "summary": "retrieving team member assignments for a specific task.", - "operationId": "getTaskAssignments", - "parameters": [ - { - "name": "taskId", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/CTaskAssignment" - } - } - } - } - } - } - }, - "post": { - "tags": [ - "ui-admin" - ], - "summary": "add a new assignment to an existing task.", - "operationId": "createAssignment", - "parameters": [ - { - "name": "taskId", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CTaskAssignment" - } - } - } - }, - "responses": { - "201": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CTaskAssignment" - } - } - } - } - } - } - }, - "/rest/task/{taskId}": { - "get": { - "tags": [ - "ui-admin" - ], - "summary": "retrieving a specific task.", - "operationId": "getTask", - "parameters": [ - { - "name": "taskId", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "default response", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/CTask" - } - } - } - } - } - }, - "put": { - "tags": [ - "ui-admin" - ], - "summary": "change an existing task.", - "operationId": "changeTask", - "parameters": [ - { - "name": "taskId", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CTask" - } - } - } - }, - "responses": { - "200": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Task" - } - } - } - } - } - }, - "delete": { - "tags": [ - "ui-admin" - ], - "summary": "delete an existing task.", - "operationId": "deleteTask", - "parameters": [ - { - "name": "taskId", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "type": "integer", - "format": "int64" - } - } - } - } - } - } - }, - "/rest/task/{taskId}/assignment/{assignmentId}": { - "put": { - "tags": [ - "ui-admin" - ], - "summary": "change from/until of given assignment", - "operationId": "changeAssignment", - "parameters": [ - { - "name": "taskId", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "assignmentId", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CTaskAssignment" - } - } - } - }, - "responses": { - "200": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CTaskAssignment" - } - } - } - } - } - }, - "delete": { - "tags": [ - "ui-admin" - ], - "summary": "delete an existing assignment from task", - "operationId": "deleteAssignment", - "parameters": [ - { - "name": "taskId", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "assignmentId", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "default response", - "content": { - "*/*": { - "schema": { - "type": "integer", - "format": "int64" - } - } - } - } - } - } - }, - "/rest/teammember": { - "get": { - "tags": [ - "ui-admin", - "ui-user" - ], - "summary": "retrieving all known users.", - "operationId": "getTeamMembers", - "responses": { - "200": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/CTeamMember" - } - } - } - } - } - } - } - }, - "/rest/workweek/{from-iso-date-string}": { - "get": { - "tags": [ - "ui-user" - ], - "summary": "retrieving work week for given week, date format: /rest/workweek/YYYY-MM-DD.", - "operationId": "getWorkWeek", - "parameters": [ - { - "name": "from-iso-date-string", - "in": "path", - "description": "date, start of week, format YYYY-MM-DD", - "required": true, - "schema": { - "type": "string" - }, - "example": "2019-03-11" - } - ], - "responses": { - "200": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/WorkWeek" - } - } - } - } - } - }, - "put": { - "tags": [ - "ui-user" - ], - "summary": "update work done for given week", - "operationId": "updateWorkWeek", - "parameters": [ - { - "name": "from-iso-date-string", - "in": "path", - "description": "date, start of week, format YYYY-MM-DD", - "required": true, - "schema": { - "type": "string" - }, - "example": "2019-03-11" - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/WorkWeek" - } - } - } - }, - "responses": { - "200": { - "description": "default response", - "content": { - "application/json": { - "schema": { - "type": "integer", - "format": "int32" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "AuthenticationRequest": { - "type": "object", - "properties": { - "userName": { - "type": "string" - }, - "password": { - "type": "string" - } - } - }, - "AuthenticationResult": { - "type": "object", - "properties": { - "ok": { - "type": "boolean" - }, - "message": { - "type": "string" - }, - "token": { - "type": "string" - } - } - }, - "CProject": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "active": { - "type": "boolean" - }, - "projectLeads": { - "type": "array", - "items": { - "$ref": "#/components/schemas/CTeamMember" - } - } - } - }, - "CTeamMember": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "userId": { - "type": "string" - } - } - }, - "CTask": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - } - } - }, - "ResponseStatusException": { - "type": "object", - "properties": { - "mostSpecificCause": { - "type": "object", - "properties": { - "stackTrace": { - "type": "array", - "items": { - "type": "object", - "properties": { - "classLoaderName": { - "type": "string" - }, - "moduleName": { - "type": "string" - }, - "moduleVersion": { - "type": "string" - }, - "methodName": { - "type": "string" - }, - "fileName": { - "type": "string" - }, - "lineNumber": { - "type": "integer", - "format": "int32" - }, - "className": { - "type": "string" - }, - "nativeMethod": { - "type": "boolean" - } - } - } - }, - "message": { - "type": "string" - }, - "suppressed": { - "type": "array", - "items": { - "type": "object", - "properties": { - "stackTrace": { - "type": "array", - "items": { - "type": "object", - "properties": { - "classLoaderName": { - "type": "string" - }, - "moduleName": { - "type": "string" - }, - "moduleVersion": { - "type": "string" - }, - "methodName": { - "type": "string" - }, - "fileName": { - "type": "string" - }, - "lineNumber": { - "type": "integer", - "format": "int32" - }, - "className": { - "type": "string" - }, - "nativeMethod": { - "type": "boolean" - } - } - } - }, - "message": { - "type": "string" - }, - "localizedMessage": { - "type": "string" - } - } - } - }, - "localizedMessage": { - "type": "string" - } - } - }, - "stackTrace": { - "type": "array", - "items": { - "type": "object", - "properties": { - "classLoaderName": { - "type": "string" - }, - "moduleName": { - "type": "string" - }, - "moduleVersion": { - "type": "string" - }, - "methodName": { - "type": "string" - }, - "fileName": { - "type": "string" - }, - "lineNumber": { - "type": "integer", - "format": "int32" - }, - "className": { - "type": "string" - }, - "nativeMethod": { - "type": "boolean" - } - } - } - }, - "status": { - "type": "string", - "enum": [ - "100 CONTINUE", - "101 SWITCHING_PROTOCOLS", - "102 PROCESSING", - "103 CHECKPOINT", - "200 OK", - "201 CREATED", - "202 ACCEPTED", - "203 NON_AUTHORITATIVE_INFORMATION", - "204 NO_CONTENT", - "205 RESET_CONTENT", - "206 PARTIAL_CONTENT", - "207 MULTI_STATUS", - "208 ALREADY_REPORTED", - "226 IM_USED", - "300 MULTIPLE_CHOICES", - "301 MOVED_PERMANENTLY", - "302 FOUND", - "302 MOVED_TEMPORARILY", - "303 SEE_OTHER", - "304 NOT_MODIFIED", - "305 USE_PROXY", - "307 TEMPORARY_REDIRECT", - "308 PERMANENT_REDIRECT", - "400 BAD_REQUEST", - "401 UNAUTHORIZED", - "402 PAYMENT_REQUIRED", - "403 FORBIDDEN", - "404 NOT_FOUND", - "405 METHOD_NOT_ALLOWED", - "406 NOT_ACCEPTABLE", - "407 PROXY_AUTHENTICATION_REQUIRED", - "408 REQUEST_TIMEOUT", - "409 CONFLICT", - "410 GONE", - "411 LENGTH_REQUIRED", - "412 PRECONDITION_FAILED", - "413 PAYLOAD_TOO_LARGE", - "413 REQUEST_ENTITY_TOO_LARGE", - "414 URI_TOO_LONG", - "414 REQUEST_URI_TOO_LONG", - "415 UNSUPPORTED_MEDIA_TYPE", - "416 REQUESTED_RANGE_NOT_SATISFIABLE", - "417 EXPECTATION_FAILED", - "418 I_AM_A_TEAPOT", - "419 INSUFFICIENT_SPACE_ON_RESOURCE", - "420 METHOD_FAILURE", - "421 DESTINATION_LOCKED", - "422 UNPROCESSABLE_ENTITY", - "423 LOCKED", - "424 FAILED_DEPENDENCY", - "425 TOO_EARLY", - "426 UPGRADE_REQUIRED", - "428 PRECONDITION_REQUIRED", - "429 TOO_MANY_REQUESTS", - "431 REQUEST_HEADER_FIELDS_TOO_LARGE", - "451 UNAVAILABLE_FOR_LEGAL_REASONS", - "500 INTERNAL_SERVER_ERROR", - "501 NOT_IMPLEMENTED", - "502 BAD_GATEWAY", - "503 SERVICE_UNAVAILABLE", - "504 GATEWAY_TIMEOUT", - "505 HTTP_VERSION_NOT_SUPPORTED", - "506 VARIANT_ALSO_NEGOTIATES", - "507 INSUFFICIENT_STORAGE", - "508 LOOP_DETECTED", - "509 BANDWIDTH_LIMIT_EXCEEDED", - "510 NOT_EXTENDED", - "511 NETWORK_AUTHENTICATION_REQUIRED" - ] - }, - "reason": { - "type": "string" - }, - "message": { - "type": "string" - }, - "rootCause": { - "type": "object", - "properties": { - "cause": { - "type": "object", - "properties": { - "stackTrace": { - "type": "array", - "items": { - "type": "object", - "properties": { - "classLoaderName": { - "type": "string" - }, - "moduleName": { - "type": "string" - }, - "moduleVersion": { - "type": "string" - }, - "methodName": { - "type": "string" - }, - "fileName": { - "type": "string" - }, - "lineNumber": { - "type": "integer", - "format": "int32" - }, - "className": { - "type": "string" - }, - "nativeMethod": { - "type": "boolean" - } - } - } - }, - "message": { - "type": "string" - }, - "suppressed": { - "type": "array", - "items": { - "type": "object", - "properties": { - "stackTrace": { - "type": "array", - "items": { - "type": "object", - "properties": { - "classLoaderName": { - "type": "string" - }, - "moduleName": { - "type": "string" - }, - "moduleVersion": { - "type": "string" - }, - "methodName": { - "type": "string" - }, - "fileName": { - "type": "string" - }, - "lineNumber": { - "type": "integer", - "format": "int32" - }, - "className": { - "type": "string" - }, - "nativeMethod": { - "type": "boolean" - } - } - } - }, - "message": { - "type": "string" - }, - "localizedMessage": { - "type": "string" - } - } - } - }, - "localizedMessage": { - "type": "string" - } - } - }, - "stackTrace": { - "type": "array", - "items": { - "type": "object", - "properties": { - "classLoaderName": { - "type": "string" - }, - "moduleName": { - "type": "string" - }, - "moduleVersion": { - "type": "string" - }, - "methodName": { - "type": "string" - }, - "fileName": { - "type": "string" - }, - "lineNumber": { - "type": "integer", - "format": "int32" - }, - "className": { - "type": "string" - }, - "nativeMethod": { - "type": "boolean" - } - } - } - }, - "message": { - "type": "string" - }, - "suppressed": { - "type": "array", - "items": { - "type": "object", - "properties": { - "stackTrace": { - "type": "array", - "items": { - "type": "object", - "properties": { - "classLoaderName": { - "type": "string" - }, - "moduleName": { - "type": "string" - }, - "moduleVersion": { - "type": "string" - }, - "methodName": { - "type": "string" - }, - "fileName": { - "type": "string" - }, - "lineNumber": { - "type": "integer", - "format": "int32" - }, - "className": { - "type": "string" - }, - "nativeMethod": { - "type": "boolean" - } - } - } - }, - "message": { - "type": "string" - }, - "localizedMessage": { - "type": "string" - } - } - } - }, - "localizedMessage": { - "type": "string" - } - } - }, - "suppressed": { - "type": "array", - "items": { - "type": "object", - "properties": { - "stackTrace": { - "type": "array", - "items": { - "type": "object", - "properties": { - "classLoaderName": { - "type": "string" - }, - "moduleName": { - "type": "string" - }, - "moduleVersion": { - "type": "string" - }, - "methodName": { - "type": "string" - }, - "fileName": { - "type": "string" - }, - "lineNumber": { - "type": "integer", - "format": "int32" - }, - "className": { - "type": "string" - }, - "nativeMethod": { - "type": "boolean" - } - } - } - }, - "message": { - "type": "string" - }, - "localizedMessage": { - "type": "string" - } - } - } - }, - "localizedMessage": { - "type": "string" - } - } - }, - "CTaskAssignment": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "task": { - "$ref": "#/components/schemas/CTask" - }, - "teamMember": { - "$ref": "#/components/schemas/CTeamMember" - }, - "from": { - "type": "string", - "format": "date" - }, - "until": { - "type": "string", - "format": "date" - } - } - }, - "Project": { - "required": [ - "active", - "name" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "description": "unique project id.", - "format": "int64", - "example": 815 - }, - "name": { - "maxLength": 100, - "minLength": 1, - "type": "string", - "description": "unique descriptive name", - "example": "my unique project name" - }, - "active": { - "type": "boolean", - "description": "is project active for administration by project lead.", - "example": true - }, - "projectLeads": { - "type": "array", - "description": "project leads (administrator)", - "items": { - "$ref": "#/components/schemas/TeamMember" - } - } - }, - "description": "tracked project." - }, - "Task": { - "required": [ - "name", - "project", - "state" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "maxLength": 100, - "minLength": 1, - "type": "string", - "description": "unique descriptive name", - "example": "first task: do something" - }, - "state": { - "type": "string", - "enum": [ - "PLANNED", - "ACTIVE", - "DONE" - ] - }, - "project": { - "$ref": "#/components/schemas/Project" - } - }, - "description": "a project task to be worked on." - }, - "TeamMember": { - "required": [ - "name", - "userId" - ], - "type": "object", - "properties": { - "id": { - "type": "integer", - "description": "unique internal member id", - "format": "int64", - "example": 4712 - }, - "name": { - "maxLength": 100, - "type": "string", - "description": "unique descriptive name", - "example": "Tom Teammember" - }, - "userId": { - "maxLength": 100, - "type": "string", - "description": "unique descriptive name", - "example": "tlead1" - } - }, - "description": "a team member, could be project lead or an member with assigned tasks." - }, - "TaskWeek": { - "type": "object", - "properties": { - "taskId": { - "type": "integer", - "description": "task unique id", - "format": "int64" - }, - "taskName": { - "type": "string" - }, - "workHours": { - "type": "array", - "description": "7 days array of working hours", - "items": { - "$ref": "#/components/schemas/WorkHoursAssigned" - } - } - }, - "description": "one week of working hours for a given task." - }, - "WorkHoursAssigned": { - "type": "object", - "properties": { - "workHours": { - "type": "integer", - "description": "working hours done for given task on this day", - "format": "int32" - }, - "readOnly": { - "type": "boolean", - "description": "current user is able to change values for this day and task." - } - }, - "description": "7 days array of working hours" - }, - "WorkWeek": { - "type": "object", - "properties": { - "from": { - "type": "string", - "description": "start of week", - "format": "date", - "example": "2019-01-02" - }, - "until": { - "type": "string", - "description": "last day of week", - "format": "date", - "example": "2019-01-08" - }, - "taskWeeks": { - "type": "array", - "description": "list of tasks for this week", - "items": { - "$ref": "#/components/schemas/TaskWeek" - } - } - }, - "description": "week, holds all work and working assignments." - } - }, - "securitySchemes": { - "Authentication": { - "type": "apiKey", - "description": "auth with jwt bearer token in 'Authentication' header of proctected requests.", - "name": "Authentication", - "in": "header" - } - } - } -} +{ + "openapi": "3.0.1", + "info": { + "title": "time@work rest api", + "description": "internal rest api, used by time@work angular client", + "contact": { + "name": "man@home", + "url": "https://gitlab.com/spare-time-demos/timeatwork", + "email": "man.at.home@do-not-use-this-mail.com" + }, + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0.txt" + }, + "version": "0.1" + }, + "externalDocs": { + "description": "specs", + "url": "https://gitlab.com/spare-time-demos/timeatwork/tree/master/docs/src/main/docs/features" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "ui-admin", + "description": "ui: admin and team lead api calls" + }, + { + "name": "ui-user", + "description": "ui: user api calls" + }, + { + "name": "security", + "description": "login" + }, + { + "name": "admin", + "description": "admin api, internal use" + } + ], + "paths": { + "/rest/admin/info": { + "get": { + "tags": [ + "admin" + ], + "summary": "(dummy) application info endpoint.", + "operationId": "info", + "responses": { + "200": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/rest/admin/job/usersync": { + "get": { + "tags": [ + "admin" + ], + "summary": "start background job: usersync", + "operationId": "startuserSync", + "responses": { + "200": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/authentication": { + "post": { + "tags": [ + "security" + ], + "summary": "login with username and password, getting an jwt token on successful.", + "operationId": "login", + "requestBody": { + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/AuthenticationRequest" + } + } + } + }, + "responses": { + "200": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/AuthenticationResult" + } + } + } + } + } + } + }, + "/rest/project/": { + "get": { + "tags": [ + "ui-admin" + ], + "summary": "retrieving all visible projects for current user.", + "operationId": "getProjects", + "responses": { + "200": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CProject" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "ui-admin" + ], + "summary": "create a new project.", + "operationId": "createProject", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CProject" + } + } + } + }, + "responses": { + "201": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CProject" + } + } + } + } + } + } + }, + "/rest/project/{projectId}": { + "get": { + "tags": [ + "ui-admin" + ], + "summary": "retrieving a specific visible projects for current user.", + "operationId": "getProject", + "parameters": [ + { + "name": "projectId", + "in": "path", + "description": "unique project id to find", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + }, + "example": "0185" + } + ], + "responses": { + "200": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CProject" + } + } + } + } + } + }, + "put": { + "tags": [ + "ui-admin" + ], + "summary": "change an existing project.", + "operationId": "changeProject", + "parameters": [ + { + "name": "projectId", + "in": "path", + "description": "unique project id to change", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + }, + "example": "0815" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CProject" + } + } + } + }, + "responses": { + "200": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CProject" + } + } + } + } + } + } + }, + "/rest/project/{projectId}/task": { + "get": { + "tags": [ + "ui-admin" + ], + "summary": "retrieving tasks for a specific project.", + "operationId": "getProjectTasks", + "parameters": [ + { + "name": "projectId", + "in": "path", + "description": "project id to find tasks for", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + }, + "example": "0815" + } + ], + "responses": { + "200": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CTask" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "ui-admin" + ], + "summary": "create a new task for an existing project", + "operationId": "createTaskForProject", + "parameters": [ + { + "name": "projectId", + "in": "path", + "description": "project id for task to change", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + }, + "example": "0815" + } + ], + "requestBody": { + "description": "new task data", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CTask" + } + } + }, + "required": false + }, + "responses": { + "201": { + "description": "task created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CTask" + } + } + } + }, + "403": { + "description": "not authorized as project lead or admin", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CTask" + } + } + } + }, + "404": { + "description": "project not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ResponseStatusException" + } + } + } + } + } + } + }, + "/rest/task/{taskId}/assignment": { + "get": { + "tags": [ + "ui-admin" + ], + "summary": "retrieving team member assignments for a specific task.", + "operationId": "getTaskAssignments", + "parameters": [ + { + "name": "taskId", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CTaskAssignment" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "ui-admin" + ], + "summary": "add a new assignment to an existing task.", + "operationId": "createAssignment", + "parameters": [ + { + "name": "taskId", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CTaskAssignment" + } + } + } + }, + "responses": { + "201": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CTaskAssignment" + } + } + } + } + } + } + }, + "/rest/task/{taskId}": { + "get": { + "tags": [ + "ui-admin" + ], + "summary": "retrieving a specific task.", + "operationId": "getTask", + "parameters": [ + { + "name": "taskId", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/CTask" + } + } + } + } + } + }, + "put": { + "tags": [ + "ui-admin" + ], + "summary": "change an existing task.", + "operationId": "changeTask", + "parameters": [ + { + "name": "taskId", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CTask" + } + } + } + }, + "responses": { + "200": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Task" + } + } + } + } + } + }, + "delete": { + "tags": [ + "ui-admin" + ], + "summary": "delete an existing task.", + "operationId": "deleteTask", + "parameters": [ + { + "name": "taskId", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "type": "integer", + "format": "int64" + } + } + } + } + } + } + }, + "/rest/task/{taskId}/assignment/{assignmentId}": { + "put": { + "tags": [ + "ui-admin" + ], + "summary": "change from/until of given assignment", + "operationId": "changeAssignment", + "parameters": [ + { + "name": "taskId", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "assignmentId", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CTaskAssignment" + } + } + } + }, + "responses": { + "200": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CTaskAssignment" + } + } + } + } + } + }, + "delete": { + "tags": [ + "ui-admin" + ], + "summary": "delete an existing assignment from task", + "operationId": "deleteAssignment", + "parameters": [ + { + "name": "taskId", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "assignmentId", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "type": "integer", + "format": "int64" + } + } + } + } + } + } + }, + "/rest/teammember": { + "get": { + "tags": [ + "ui-admin", + "ui-user" + ], + "summary": "retrieving all known users.", + "operationId": "getTeamMembers", + "responses": { + "200": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CTeamMember" + } + } + } + } + } + } + } + }, + "/rest/workweek/{from-iso-date-string}": { + "get": { + "tags": [ + "ui-user" + ], + "summary": "retrieving work week for given week, date format: /rest/workweek/YYYY-MM-DD.", + "operationId": "getWorkWeek", + "parameters": [ + { + "name": "from-iso-date-string", + "in": "path", + "description": "date, start of week, format YYYY-MM-DD", + "required": true, + "schema": { + "type": "string" + }, + "example": "2019-03-11" + } + ], + "responses": { + "200": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkWeek" + } + } + } + } + } + }, + "put": { + "tags": [ + "ui-user" + ], + "summary": "update work done for given week", + "operationId": "updateWorkWeek", + "parameters": [ + { + "name": "from-iso-date-string", + "in": "path", + "description": "date, start of week, format YYYY-MM-DD", + "required": true, + "schema": { + "type": "string" + }, + "example": "2019-03-11" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorkWeek" + } + } + } + }, + "responses": { + "200": { + "description": "default response", + "content": { + "application/json": { + "schema": { + "type": "integer", + "format": "int32" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AuthenticationRequest": { + "type": "object", + "properties": { + "userName": { + "type": "string" + }, + "password": { + "type": "string" + } + } + }, + "AuthenticationResult": { + "type": "object", + "properties": { + "ok": { + "type": "boolean" + }, + "message": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "CProject": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "active": { + "type": "boolean" + }, + "projectLeads": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CTeamMember" + } + } + } + }, + "CTeamMember": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "userId": { + "type": "string" + } + } + }, + "CTask": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + } + }, + "ResponseStatusException": { + "type": "object", + "properties": { + "mostSpecificCause": { + "type": "object", + "properties": { + "stackTrace": { + "type": "array", + "items": { + "type": "object", + "properties": { + "classLoaderName": { + "type": "string" + }, + "moduleName": { + "type": "string" + }, + "moduleVersion": { + "type": "string" + }, + "methodName": { + "type": "string" + }, + "fileName": { + "type": "string" + }, + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "className": { + "type": "string" + }, + "nativeMethod": { + "type": "boolean" + } + } + } + }, + "message": { + "type": "string" + }, + "suppressed": { + "type": "array", + "items": { + "type": "object", + "properties": { + "stackTrace": { + "type": "array", + "items": { + "type": "object", + "properties": { + "classLoaderName": { + "type": "string" + }, + "moduleName": { + "type": "string" + }, + "moduleVersion": { + "type": "string" + }, + "methodName": { + "type": "string" + }, + "fileName": { + "type": "string" + }, + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "className": { + "type": "string" + }, + "nativeMethod": { + "type": "boolean" + } + } + } + }, + "message": { + "type": "string" + }, + "localizedMessage": { + "type": "string" + } + } + } + }, + "localizedMessage": { + "type": "string" + } + } + }, + "stackTrace": { + "type": "array", + "items": { + "type": "object", + "properties": { + "classLoaderName": { + "type": "string" + }, + "moduleName": { + "type": "string" + }, + "moduleVersion": { + "type": "string" + }, + "methodName": { + "type": "string" + }, + "fileName": { + "type": "string" + }, + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "className": { + "type": "string" + }, + "nativeMethod": { + "type": "boolean" + } + } + } + }, + "status": { + "type": "string", + "enum": [ + "100 CONTINUE", + "101 SWITCHING_PROTOCOLS", + "102 PROCESSING", + "103 CHECKPOINT", + "200 OK", + "201 CREATED", + "202 ACCEPTED", + "203 NON_AUTHORITATIVE_INFORMATION", + "204 NO_CONTENT", + "205 RESET_CONTENT", + "206 PARTIAL_CONTENT", + "207 MULTI_STATUS", + "208 ALREADY_REPORTED", + "226 IM_USED", + "300 MULTIPLE_CHOICES", + "301 MOVED_PERMANENTLY", + "302 FOUND", + "302 MOVED_TEMPORARILY", + "303 SEE_OTHER", + "304 NOT_MODIFIED", + "305 USE_PROXY", + "307 TEMPORARY_REDIRECT", + "308 PERMANENT_REDIRECT", + "400 BAD_REQUEST", + "401 UNAUTHORIZED", + "402 PAYMENT_REQUIRED", + "403 FORBIDDEN", + "404 NOT_FOUND", + "405 METHOD_NOT_ALLOWED", + "406 NOT_ACCEPTABLE", + "407 PROXY_AUTHENTICATION_REQUIRED", + "408 REQUEST_TIMEOUT", + "409 CONFLICT", + "410 GONE", + "411 LENGTH_REQUIRED", + "412 PRECONDITION_FAILED", + "413 PAYLOAD_TOO_LARGE", + "413 REQUEST_ENTITY_TOO_LARGE", + "414 URI_TOO_LONG", + "414 REQUEST_URI_TOO_LONG", + "415 UNSUPPORTED_MEDIA_TYPE", + "416 REQUESTED_RANGE_NOT_SATISFIABLE", + "417 EXPECTATION_FAILED", + "418 I_AM_A_TEAPOT", + "419 INSUFFICIENT_SPACE_ON_RESOURCE", + "420 METHOD_FAILURE", + "421 DESTINATION_LOCKED", + "422 UNPROCESSABLE_ENTITY", + "423 LOCKED", + "424 FAILED_DEPENDENCY", + "425 TOO_EARLY", + "426 UPGRADE_REQUIRED", + "428 PRECONDITION_REQUIRED", + "429 TOO_MANY_REQUESTS", + "431 REQUEST_HEADER_FIELDS_TOO_LARGE", + "451 UNAVAILABLE_FOR_LEGAL_REASONS", + "500 INTERNAL_SERVER_ERROR", + "501 NOT_IMPLEMENTED", + "502 BAD_GATEWAY", + "503 SERVICE_UNAVAILABLE", + "504 GATEWAY_TIMEOUT", + "505 HTTP_VERSION_NOT_SUPPORTED", + "506 VARIANT_ALSO_NEGOTIATES", + "507 INSUFFICIENT_STORAGE", + "508 LOOP_DETECTED", + "509 BANDWIDTH_LIMIT_EXCEEDED", + "510 NOT_EXTENDED", + "511 NETWORK_AUTHENTICATION_REQUIRED" + ] + }, + "reason": { + "type": "string" + }, + "message": { + "type": "string" + }, + "rootCause": { + "type": "object", + "properties": { + "cause": { + "type": "object", + "properties": { + "stackTrace": { + "type": "array", + "items": { + "type": "object", + "properties": { + "classLoaderName": { + "type": "string" + }, + "moduleName": { + "type": "string" + }, + "moduleVersion": { + "type": "string" + }, + "methodName": { + "type": "string" + }, + "fileName": { + "type": "string" + }, + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "className": { + "type": "string" + }, + "nativeMethod": { + "type": "boolean" + } + } + } + }, + "message": { + "type": "string" + }, + "suppressed": { + "type": "array", + "items": { + "type": "object", + "properties": { + "stackTrace": { + "type": "array", + "items": { + "type": "object", + "properties": { + "classLoaderName": { + "type": "string" + }, + "moduleName": { + "type": "string" + }, + "moduleVersion": { + "type": "string" + }, + "methodName": { + "type": "string" + }, + "fileName": { + "type": "string" + }, + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "className": { + "type": "string" + }, + "nativeMethod": { + "type": "boolean" + } + } + } + }, + "message": { + "type": "string" + }, + "localizedMessage": { + "type": "string" + } + } + } + }, + "localizedMessage": { + "type": "string" + } + } + }, + "stackTrace": { + "type": "array", + "items": { + "type": "object", + "properties": { + "classLoaderName": { + "type": "string" + }, + "moduleName": { + "type": "string" + }, + "moduleVersion": { + "type": "string" + }, + "methodName": { + "type": "string" + }, + "fileName": { + "type": "string" + }, + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "className": { + "type": "string" + }, + "nativeMethod": { + "type": "boolean" + } + } + } + }, + "message": { + "type": "string" + }, + "suppressed": { + "type": "array", + "items": { + "type": "object", + "properties": { + "stackTrace": { + "type": "array", + "items": { + "type": "object", + "properties": { + "classLoaderName": { + "type": "string" + }, + "moduleName": { + "type": "string" + }, + "moduleVersion": { + "type": "string" + }, + "methodName": { + "type": "string" + }, + "fileName": { + "type": "string" + }, + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "className": { + "type": "string" + }, + "nativeMethod": { + "type": "boolean" + } + } + } + }, + "message": { + "type": "string" + }, + "localizedMessage": { + "type": "string" + } + } + } + }, + "localizedMessage": { + "type": "string" + } + } + }, + "suppressed": { + "type": "array", + "items": { + "type": "object", + "properties": { + "stackTrace": { + "type": "array", + "items": { + "type": "object", + "properties": { + "classLoaderName": { + "type": "string" + }, + "moduleName": { + "type": "string" + }, + "moduleVersion": { + "type": "string" + }, + "methodName": { + "type": "string" + }, + "fileName": { + "type": "string" + }, + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "className": { + "type": "string" + }, + "nativeMethod": { + "type": "boolean" + } + } + } + }, + "message": { + "type": "string" + }, + "localizedMessage": { + "type": "string" + } + } + } + }, + "localizedMessage": { + "type": "string" + } + } + }, + "CTaskAssignment": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "task": { + "$ref": "#/components/schemas/CTask" + }, + "teamMember": { + "$ref": "#/components/schemas/CTeamMember" + }, + "from": { + "type": "string", + "format": "date" + }, + "until": { + "type": "string", + "format": "date" + } + } + }, + "Project": { + "required": [ + "active", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "unique project id.", + "format": "int64", + "example": 815 + }, + "name": { + "maxLength": 100, + "minLength": 1, + "type": "string", + "description": "unique descriptive name", + "example": "my unique project name" + }, + "active": { + "type": "boolean", + "description": "is project active for administration by project lead.", + "example": true + }, + "projectLeads": { + "type": "array", + "description": "project leads (administrator)", + "items": { + "$ref": "#/components/schemas/TeamMember" + } + } + }, + "description": "tracked project." + }, + "Task": { + "required": [ + "name", + "project", + "state" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "maxLength": 100, + "minLength": 1, + "type": "string", + "description": "unique descriptive name", + "example": "first task: do something" + }, + "state": { + "type": "string", + "enum": [ + "PLANNED", + "ACTIVE", + "DONE" + ] + }, + "project": { + "$ref": "#/components/schemas/Project" + } + }, + "description": "a project task to be worked on." + }, + "TeamMember": { + "required": [ + "name", + "userId" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "unique internal member id", + "format": "int64", + "example": 4712 + }, + "name": { + "maxLength": 100, + "type": "string", + "description": "unique descriptive name", + "example": "Tom Teammember" + }, + "userId": { + "maxLength": 100, + "type": "string", + "description": "unique descriptive name", + "example": "tlead1" + } + }, + "description": "a team member, could be project lead or an member with assigned tasks." + }, + "TaskWeek": { + "type": "object", + "properties": { + "taskId": { + "type": "integer", + "description": "task unique id", + "format": "int64" + }, + "taskName": { + "type": "string" + }, + "workHours": { + "type": "array", + "description": "7 days array of working hours", + "items": { + "$ref": "#/components/schemas/WorkHoursAssigned" + } + } + }, + "description": "one week of working hours for a given task." + }, + "WorkHoursAssigned": { + "type": "object", + "properties": { + "workHours": { + "type": "integer", + "description": "working hours done for given task on this day", + "format": "int32" + }, + "readOnly": { + "type": "boolean", + "description": "current user is able to change values for this day and task." + } + }, + "description": "7 days array of working hours" + }, + "WorkWeek": { + "type": "object", + "properties": { + "from": { + "type": "string", + "description": "start of week", + "format": "date", + "example": "2019-01-02" + }, + "until": { + "type": "string", + "description": "last day of week", + "format": "date", + "example": "2019-01-08" + }, + "taskWeeks": { + "type": "array", + "description": "list of tasks for this week", + "items": { + "$ref": "#/components/schemas/TaskWeek" + } + } + }, + "description": "week, holds all work and working assignments." + } + }, + "securitySchemes": { + "Authentication": { + "type": "apiKey", + "description": "auth with jwt bearer token in 'Authentication' header of proctected requests.", + "name": "Authentication", + "in": "header" + } + } + } +} diff --git a/modules/openapi-generator/src/test/resources/3_0/asciidoc/generated-snippets/rest/project/GET/GET.json b/modules/openapi-generator/src/test/resources/3_0/asciidoc/generated-snippets/rest/project/GET/GET.json index 0538e0fb212..b4d6eec7ef8 100644 --- a/modules/openapi-generator/src/test/resources/3_0/asciidoc/generated-snippets/rest/project/GET/GET.json +++ b/modules/openapi-generator/src/test/resources/3_0/asciidoc/generated-snippets/rest/project/GET/GET.json @@ -1,16 +1,16 @@ -{ - "id" : "238a47e3-2533-41a4-ac62-f6654c936ada", - "request" : { - "url" : "/rest/project/", - "method" : "GET" - }, - "response" : { - "status" : 200, - "body" : "[{\"id\":-3,\"name\":\"a third inactive project\",\"active\":false,\"projectLeads\":[{\"id\":-2,\"name\":\"another second lead\",\"userId\":\"tlead2\"},{\"id\":-1,\"name\":\"a first test lead and user\",\"userId\":\"tlead1\"}]},{\"id\":-2,\"name\":\"a second active project\",\"active\":true,\"projectLeads\":[{\"id\":-1,\"name\":\"a first test lead and user\",\"userId\":\"tlead1\"}]},{\"id\":-1,\"name\":\"a first active project\",\"active\":true,\"projectLeads\":[{\"id\":-2,\"name\":\"another second lead\",\"userId\":\"tlead2\"},{\"id\":-1,\"name\":\"a first test lead and user\",\"userId\":\"tlead1\"}]}]", - "headers" : { - "Vary" : [ "Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers" ], - "Content-Type" : "application/json" - } - }, - "uuid" : "238a47e3-2533-41a4-ac62-f6654c936ada" +{ + "id" : "238a47e3-2533-41a4-ac62-f6654c936ada", + "request" : { + "url" : "/rest/project/", + "method" : "GET" + }, + "response" : { + "status" : 200, + "body" : "[{\"id\":-3,\"name\":\"a third inactive project\",\"active\":false,\"projectLeads\":[{\"id\":-2,\"name\":\"another second lead\",\"userId\":\"tlead2\"},{\"id\":-1,\"name\":\"a first test lead and user\",\"userId\":\"tlead1\"}]},{\"id\":-2,\"name\":\"a second active project\",\"active\":true,\"projectLeads\":[{\"id\":-1,\"name\":\"a first test lead and user\",\"userId\":\"tlead1\"}]},{\"id\":-1,\"name\":\"a first active project\",\"active\":true,\"projectLeads\":[{\"id\":-2,\"name\":\"another second lead\",\"userId\":\"tlead2\"},{\"id\":-1,\"name\":\"a first test lead and user\",\"userId\":\"tlead1\"}]}]", + "headers" : { + "Vary" : [ "Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers" ], + "Content-Type" : "application/json" + } + }, + "uuid" : "238a47e3-2533-41a4-ac62-f6654c936ada" } \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/asciidoc/generated-snippets/rest/project/GET/http-response.adoc b/modules/openapi-generator/src/test/resources/3_0/asciidoc/generated-snippets/rest/project/GET/http-response.adoc index 15f6735316d..15d42cf5cbe 100644 --- a/modules/openapi-generator/src/test/resources/3_0/asciidoc/generated-snippets/rest/project/GET/http-response.adoc +++ b/modules/openapi-generator/src/test/resources/3_0/asciidoc/generated-snippets/rest/project/GET/http-response.adoc @@ -6,6 +6,6 @@ Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Content-Type: application/json;charset=UTF-8 Content-Length: 530 - + [{"id":-3,"name":"a third inactive project","active":false,"projectLeads":[{"id":-1,"name":"a first test lead and user","userId":"tlead1"},{"id":-2,"name":"another second lead","userId":"tlead2"}]},{"id":-2,"name":"a second active project","active":true,"projectLeads":[{"id":-1,"name":"a first test lead and user","userId":"tlead1"}]},{"id":-1,"name":"a first active project","active":true,"projectLeads":[{"id":-1,"name":"a first test lead and user","userId":"tlead1"},{"id":-2,"name":"another second lead","userId":"tlead2"}]}] ---- \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/asciidoc/specs/rest/project/GET/implementation.adoc b/modules/openapi-generator/src/test/resources/3_0/asciidoc/specs/rest/project/GET/implementation.adoc index 2713f95e67a..c2479c76872 100644 --- a/modules/openapi-generator/src/test/resources/3_0/asciidoc/specs/rest/project/GET/implementation.adoc +++ b/modules/openapi-generator/src/test/resources/3_0/asciidoc/specs/rest/project/GET/implementation.adoc @@ -1,2 +1,2 @@ - + // optional, conditionally included implementation notes. \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/asciidoc/specs/rest/project/GET/spec.adoc b/modules/openapi-generator/src/test/resources/3_0/asciidoc/specs/rest/project/GET/spec.adoc index b916c8d6bc6..389ce757a71 100644 --- a/modules/openapi-generator/src/test/resources/3_0/asciidoc/specs/rest/project/GET/spec.adoc +++ b/modules/openapi-generator/src/test/resources/3_0/asciidoc/specs/rest/project/GET/spec.adoc @@ -1,7 +1,7 @@ -// spec to include - -* all _projects_ visible for the _current user_ are returned -* _projects_ may be active or closed - -USER: project lead, admin - +// spec to include + +* all _projects_ visible for the _current user_ are returned +* _projects_ may be active or closed + +USER: project lead, admin + diff --git a/mvnw.cmd b/mvnw.cmd index 23ab056e297..e506408e362 100755 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -1,145 +1,145 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/samples/client/petstore/kotlin-multiplatform/gradlew.bat b/samples/client/petstore/kotlin-multiplatform/gradlew.bat index 24467a141f7..9618d8d9607 100644 --- a/samples/client/petstore/kotlin-multiplatform/gradlew.bat +++ b/samples/client/petstore/kotlin-multiplatform/gradlew.bat @@ -1,100 +1,100 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/client/petstore/kotlin/gradlew.bat b/samples/client/petstore/kotlin/gradlew.bat index e95643d6a2c..f9553162f12 100644 --- a/samples/client/petstore/kotlin/gradlew.bat +++ b/samples/client/petstore/kotlin/gradlew.bat @@ -1,84 +1,84 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/meta-codegen-kotlin/gradlew.bat b/samples/meta-codegen-kotlin/gradlew.bat index 24467a141f7..9618d8d9607 100644 --- a/samples/meta-codegen-kotlin/gradlew.bat +++ b/samples/meta-codegen-kotlin/gradlew.bat @@ -1,100 +1,100 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/website/static/img/companies/angular-schule.svg b/website/static/img/companies/angular-schule.svg index ca423caf14d..951ce61f808 100644 --- a/website/static/img/companies/angular-schule.svg +++ b/website/static/img/companies/angular-schule.svg @@ -1,89 +1,89 @@ - - - - - - brand - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + brand + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +