From 92daacd6a25873847886ac2360193a1303208300 Mon Sep 17 00:00:00 2001 From: Cosmin Poieana Date: Thu, 9 Nov 2023 11:06:28 +0200 Subject: [PATCH 01/12] Add Robocorp (robocorp.com) as user (#17019) * Add Robocorp (robocorp.com) as user * Reference Robocorp into the README --- README.md | 1 + website/src/dynamic/users.yml | 5 ++ website/static/img/companies/robocorp.svg | 68 +++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 website/static/img/companies/robocorp.svg diff --git a/README.md b/README.md index 94a565c92e10..04b38af027e7 100644 --- a/README.md +++ b/README.md @@ -694,6 +694,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in - [RedHat](https://www.redhat.com) - [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development) - [REST United](https://restunited.com) +- [Robocorp](https://www.robocorp.com) - [Robotinfra](https://www.robotinfra.com) - [SmartHR](https://smarthr.co.jp/) - [Sony Interactive Entertainment](https://www.sie.com/en/index.html) diff --git a/website/src/dynamic/users.yml b/website/src/dynamic/users.yml index ccf60cbb81b9..751ebb3776e8 100644 --- a/website/src/dynamic/users.yml +++ b/website/src/dynamic/users.yml @@ -443,6 +443,11 @@ image: "img/companies/puppet.svg" infoLink: "https://www.puppet.com" pinned: false +- + caption: Robocorp + image: "img/companies/robocorp.svg" + infoLink: "https://www.robocorp.com" + pinned: false - caption: Qovery image: "img/companies/qovery.png" diff --git a/website/static/img/companies/robocorp.svg b/website/static/img/companies/robocorp.svg new file mode 100644 index 000000000000..98798ed78057 --- /dev/null +++ b/website/static/img/companies/robocorp.svg @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + From c48cddd6408b8ead8db1b62832167978c5d97a70 Mon Sep 17 00:00:00 2001 From: Aidan Date: Sat, 11 Nov 2023 00:10:42 -0800 Subject: [PATCH 02/12] [GO] Add support for model name mapping for go (#17023) * Add support for model name mapping for go Signed-off-by: Aidan Jensen * Add model name and filename tests Signed-off-by: Aidan * Use File.separator to make the test platform agnostic Signed-off-by: Aidan --------- Signed-off-by: Aidan Jensen Signed-off-by: Aidan --- .../codegen/languages/AbstractGoCodegen.java | 9 +++++++ .../openapitools/codegen/go/GoModelTest.java | 26 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java index 50eda6dddadf..8b5fd016501a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java @@ -280,6 +280,10 @@ protected boolean isReservedFilename(String name) { @Override public String toModelFilename(String name) { + // Obtain the model name from modelNameMapping directly if provided + if (modelNameMapping.containsKey(name)) { + name = modelNameMapping.get(name); + } name = toModel("model_" + name); if (isReservedFilename(name)) { @@ -295,6 +299,11 @@ public String toModel(String name) { } public String toModel(String name, boolean doUnderscore) { + // obtain the name from modelNameMapping directly if provided + if (modelNameMapping.containsKey(name)) { + return modelNameMapping.get(name); + } + if (!StringUtils.isEmpty(modelNamePrefix)) { name = modelNamePrefix + "_" + name; } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoModelTest.java index ca3a2f66b6fd..f84c74d8ee1a 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoModelTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoModelTest.java @@ -30,6 +30,8 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import java.io.File; + @SuppressWarnings("static-method") public class GoModelTest { @@ -298,4 +300,28 @@ public void modelNameTest(String name, String expectedName) { Assert.assertEquals(cm.name, name); Assert.assertEquals(cm.classname, expectedName); } + + @DataProvider(name = "modelMappedNames") + public static Object[][] mappedNames() { + return new Object[][] { + {"mapped", "Remapped", "model_remapped.go"}, + {"mapped_underscore", "RemappedUnderscore", "model_remapped_underscore.go"}, + }; + } + + @Test(dataProvider = "modelMappedNames", description = "map model names") + public void modelNameMappingsTest(String name, String expectedName, String expectedFilename) { + final Schema model = new Schema(); + final DefaultCodegen codegen = new GoClientCodegen(); + codegen.modelNameMapping().put(name, expectedName); + OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema(name, model); + codegen.setOpenAPI(openAPI); + final CodegenModel cm = codegen.fromModel(name, model); + + final String fn = codegen.modelFilename("model.mustache", name, ""); + Assert.assertEquals(fn, File.separator + expectedFilename); + + Assert.assertEquals(cm.name, name); + Assert.assertEquals(cm.classname, expectedName); + } } From 279a92c2eda7b3ea9e0472b9e615c6725df7a379 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 11 Nov 2023 16:31:23 +0800 Subject: [PATCH 03/12] rearrange users --- website/src/dynamic/users.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/website/src/dynamic/users.yml b/website/src/dynamic/users.yml index 751ebb3776e8..be7c751c0ba8 100644 --- a/website/src/dynamic/users.yml +++ b/website/src/dynamic/users.yml @@ -443,11 +443,6 @@ image: "img/companies/puppet.svg" infoLink: "https://www.puppet.com" pinned: false -- - caption: Robocorp - image: "img/companies/robocorp.svg" - infoLink: "https://www.robocorp.com" - pinned: false - caption: Qovery image: "img/companies/qovery.png" @@ -483,6 +478,11 @@ image: "img/companies/rest-united.png" infoLink: "https://restunited.com/" pinned: false +- + caption: Robocorp + image: "img/companies/robocorp.svg" + infoLink: "https://www.robocorp.com" + pinned: false - caption: "Shotstack" image: "img/companies/shotstack.svg" From 09060c6c22dbad88beedd5713e14d6cb6036119e Mon Sep 17 00:00:00 2001 From: Beppe Catanese <1771700+gcatanese@users.noreply.github.com> Date: Sat, 11 Nov 2023 17:08:07 +0100 Subject: [PATCH 04/12] Use postman notation (#17028) * use Postman notation for path parameter * Regenerate samples --- .../languages/PostmanCollectionCodegen.java | 14 +++++++++----- .../resources/postman-collection/item.mustache | 2 +- .../postman/PostmanCollectionCodegenTest.java | 13 ++++++++++--- samples/schema/postman-collection/postman.json | 2 +- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PostmanCollectionCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PostmanCollectionCodegen.java index 028667f18701..71d5609cc4c2 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PostmanCollectionCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PostmanCollectionCodegen.java @@ -131,6 +131,7 @@ public PostmanCollectionCodegen() { @Override public void postProcessParameter(CodegenParameter parameter) { + // create Postman variable from every path parameter if(pathParamsAsVariables && parameter.isPathParam) { variables.add(new PostmanVariable() .addName(parameter.paramName) @@ -216,13 +217,16 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List Date: Sun, 12 Nov 2023 22:01:43 +0800 Subject: [PATCH 05/12] Update gradle samples to use gradle wrapper 7.6.3 (#17035) * trigger gradle build * update gradlew to use 7.x --- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../samples/local-spec/gradlew | 271 +++++++++++------- .../samples/local-spec/gradlew.bat | 15 +- .../gradle/plugin/OpenApiGeneratorPlugin.kt | 2 + 4 files changed, 178 insertions(+), 112 deletions(-) diff --git a/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle/wrapper/gradle-wrapper.properties b/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle/wrapper/gradle-wrapper.properties index 442d9132ea32..068cdb2dc260 100644 --- a/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle/wrapper/gradle-wrapper.properties +++ b/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/modules/openapi-generator-gradle-plugin/samples/local-spec/gradlew b/modules/openapi-generator-gradle-plugin/samples/local-spec/gradlew index 20b741fb46c3..cc8078650258 100755 --- a/modules/openapi-generator-gradle-plugin/samples/local-spec/gradlew +++ b/modules/openapi-generator-gradle-plugin/samples/local-spec/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,97 +121,124 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" 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 6a68175eb70f..ea603b410240 100644 --- a/modules/openapi-generator-gradle-plugin/samples/local-spec/gradlew.bat +++ b/modules/openapi-generator-gradle-plugin/samples/local-spec/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 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 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt index 3947d3806ee4..cf3552d38fb5 100644 --- a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt +++ b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt @@ -163,3 +163,5 @@ class OpenApiGeneratorPlugin : Plugin { } } + + From 2b9ee8c5f6818b7313aaf7b3e427908f78790e47 Mon Sep 17 00:00:00 2001 From: Beppe Catanese <1771700+gcatanese@users.noreply.github.com> Date: Sun, 12 Nov 2023 16:10:15 +0100 Subject: [PATCH 06/12] Remove unused method (#17042) --- .../languages/PostmanCollectionCodegen.java | 11 ----------- .../postman/PostmanCollectionCodegenTest.java | 14 -------------- 2 files changed, 25 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PostmanCollectionCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PostmanCollectionCodegen.java index 71d5609cc4c2..296347ab720e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PostmanCollectionCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PostmanCollectionCodegen.java @@ -505,17 +505,6 @@ public String escapeQuotationMark(String input) { return input.replace("\"", "\\\""); } - public String doubleCurlyBraces(String str) { - - // remove doublebraces first - String s = str.replace("{{", "{").replace("}}", "}"); - // change all singlebraces to doublebraces - s = s.replace("{", "{{").replace("}", "}}"); - - return s; - - } - // convert path from /users/{id} to /users/:id String replacesBracesInPath(String path) { diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/postman/PostmanCollectionCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/postman/PostmanCollectionCodegenTest.java index f5e2366e9668..4463a2c5c089 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/postman/PostmanCollectionCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/postman/PostmanCollectionCodegenTest.java @@ -364,20 +364,6 @@ public void testSecuritySchemes() throws Exception { assertFileNotContains(path, "\"auth\": { \"type\": \"apikey\", \"apikey\": ["); } - @Test - public void doubleCurlyBraces() { - String str = "/api/{var}/archive"; - - assertEquals("/api/{{var}}/archive", new PostmanCollectionCodegen().doubleCurlyBraces(str)); - } - - @Test - public void doubleCurlyBracesNoChanges() { - String str = "/api/{{var}}/archive"; - - assertEquals("/api/{{var}}/archive", new PostmanCollectionCodegen().doubleCurlyBraces(str)); - } - @Test public void extractExampleByName() { String str = "#/components/examples/get-user-basic"; From 6917aad7601638f689c01f45f0cd4bece1d9ea2d Mon Sep 17 00:00:00 2001 From: Elon Mallin Date: Sun, 12 Nov 2023 16:18:12 +0100 Subject: [PATCH 07/12] fix: use apikey name in header instead of securityDefinition spec id (#17022) --- .../src/main/resources/powershell/api.mustache | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/powershell/api.mustache b/modules/openapi-generator/src/main/resources/powershell/api.mustache index e94ffd28275c..79d632682cf3 100644 --- a/modules/openapi-generator/src/main/resources/powershell/api.mustache +++ b/modules/openapi-generator/src/main/resources/powershell/api.mustache @@ -178,15 +178,15 @@ function {{{vendorExtensions.x-powershell-method-name}}} { {{#authMethods}} {{#isApiKey}} {{#isKeyInHeader}} - if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["{{{name}}}"]) { - $LocalVarHeaderParameters['{{{name}}}'] = $Configuration["ApiKey"]["{{{name}}}"] - Write-Verbose ("Using API key '{{{name}}}' in the header for authentication in {0}" -f $MyInvocation.MyCommand) + if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["{{{keyParamName}}}"]) { + $LocalVarHeaderParameters['{{{keyParamName}}}'] = $Configuration["ApiKey"]["{{{keyParamName}}}"] + Write-Verbose ("Using API key '{{{keyParamName}}}' in the header for authentication in {0}" -f $MyInvocation.MyCommand) } {{/isKeyInHeader}} {{#isKeyInQuery}} - if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["{{{name}}}"]) { - $LocalVarQueryParameters['{{{name}}}'] = $Configuration["ApiKey"]["{{{name}}}"] - Write-Verbose ("Using API key `{{{name}}}` in the URL query for authentication in {0}" -f $MyInvocation.MyCommand) + if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["{{{keyParamName}}}"]) { + $LocalVarQueryParameters['{{{keyParamName}}}'] = $Configuration["ApiKey"]["{{{keyParamName}}}"] + Write-Verbose ("Using API key `{{{keyParamName}}}` in the URL query for authentication in {0}" -f $MyInvocation.MyCommand) } {{/isKeyInQuery}} {{#isKeyInCookie}} From 372894dd1d932f7f8e67b29b68be56d4b0c08a84 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 13 Nov 2023 00:09:46 +0800 Subject: [PATCH 08/12] Add powershell echo test, rename api key names (#17043) * add powershell echo test, rename api key names * update --- bin/configs/powershell-echo-api.yaml | 7 + ...odels-for-testing-with-http-signature.yaml | 4 +- .../powershell/.openapi-generator-ignore | 23 + .../powershell/.openapi-generator/FILES | 45 ++ .../powershell/.openapi-generator/VERSION | 1 + samples/client/echo_api/powershell/Build.ps1 | 73 ++ samples/client/echo_api/powershell/README.md | 102 +++ .../client/echo_api/powershell/appveyor.yml | 41 ++ .../echo_api/powershell/docs/AuthApi.md | 53 ++ .../client/echo_api/powershell/docs/Bird.md | 23 + .../echo_api/powershell/docs/BodyApi.md | 361 ++++++++++ .../echo_api/powershell/docs/Category.md | 23 + .../echo_api/powershell/docs/DataQuery.md | 29 + .../echo_api/powershell/docs/DefaultValue.md | 35 + .../echo_api/powershell/docs/FormApi.md | 117 ++++ .../echo_api/powershell/docs/HeaderApi.md | 64 ++ .../powershell/docs/NumberPropertiesOnly.md | 25 + .../echo_api/powershell/docs/PathApi.md | 61 ++ .../client/echo_api/powershell/docs/Pet.md | 31 + .../client/echo_api/powershell/docs/Query.md | 23 + .../echo_api/powershell/docs/QueryApi.md | 379 +++++++++++ .../echo_api/powershell/docs/StringEnumRef.md | 20 + .../client/echo_api/powershell/docs/Tag.md | 23 + ...lodeTrueObjectAllOfQueryObjectParameter.md | 27 + ...lodeTrueArrayStringQueryObjectParameter.md | 21 + .../src/PSOpenAPITools/Api/AuthApi.ps1 | 78 +++ .../src/PSOpenAPITools/Api/BodyApi.ps1 | 592 ++++++++++++++++ .../src/PSOpenAPITools/Api/FormApi.ps1 | 230 +++++++ .../src/PSOpenAPITools/Api/HeaderApi.ps1 | 122 ++++ .../src/PSOpenAPITools/Api/PathApi.ps1 | 112 +++ .../src/PSOpenAPITools/Api/QueryApi.ps1 | 643 ++++++++++++++++++ .../PSOpenAPITools/Client/Configuration.ps1 | 515 ++++++++++++++ .../src/PSOpenAPITools/Model/Bird.ps1 | 111 +++ .../src/PSOpenAPITools/Model/Category.ps1 | 111 +++ .../src/PSOpenAPITools/Model/DataQuery.ps1 | 151 ++++ .../src/PSOpenAPITools/Model/DefaultValue.ps1 | 190 ++++++ .../Model/NumberPropertiesOnly.ps1 | 132 ++++ .../src/PSOpenAPITools/Model/Pet.ps1 | 176 +++++ .../src/PSOpenAPITools/Model/Query.ps1 | 112 +++ .../PSOpenAPITools/Model/StringEnumRef.ps1 | 27 + .../src/PSOpenAPITools/Model/Tag.ps1 | 111 +++ ...odeTrueObjectAllOfQueryObjectParameter.ps1 | 137 ++++ ...odeTrueArrayStringQueryObjectParameter.ps1 | 98 +++ .../src/PSOpenAPITools/PSOpenAPITools.psm1 | 38 ++ .../src/PSOpenAPITools/Private/ApiClient.ps1 | 260 +++++++ .../Private/Get-CommonParameters.ps1 | 22 + .../Private/HttpSignatureAuth.ps1 | 437 ++++++++++++ .../Private/Out-DebugParameter.ps1 | 45 ++ .../Private/RSAEncryptionProvider.cs | 354 ++++++++++ .../en-US/about_PSOpenAPITools.help.txt | 19 + .../powershell/tests/Api/AuthApi.Tests.ps1 | 18 + .../powershell/tests/Api/BodyApi.Tests.ps1 | 74 ++ .../powershell/tests/Api/FormApi.Tests.ps1 | 26 + .../powershell/tests/Api/HeaderApi.Tests.ps1 | 18 + .../powershell/tests/Api/PathApi.Tests.ps1 | 18 + .../powershell/tests/Api/QueryApi.Tests.ps1 | 74 ++ .../powershell/tests/Model/Bird.Tests.ps1 | 18 + .../powershell/tests/Model/Category.Tests.ps1 | 18 + .../tests/Model/DataQuery.Tests.ps1 | 18 + .../tests/Model/DefaultValue.Tests.ps1 | 18 + .../Model/NumberPropertiesOnly.Tests.ps1 | 18 + .../powershell/tests/Model/Pet.Tests.ps1 | 18 + .../powershell/tests/Model/Query.Tests.ps1 | 18 + .../tests/Model/StringEnumRef.Tests.ps1 | 18 + .../powershell/tests/Model/Tag.Tests.ps1 | 18 + ...eObjectAllOfQueryObjectParameter.Tests.ps1 | 18 + ...eArrayStringQueryObjectParameter.Tests.ps1 | 18 + samples/client/petstore/powershell/README.md | 4 +- .../docs/PSFakeClassnameTags123Api.md | 4 +- .../petstore/powershell/docs/PSPetApi.md | 4 +- .../petstore/powershell/docs/PSStoreApi.md | 4 +- .../Api/PSFakeClassnameTags123Api.ps1 | 6 +- .../src/PSPetstore/Api/PSPetApi.ps1 | 6 +- .../src/PSPetstore/Api/PSStoreApi.ps1 | 6 +- 74 files changed, 6875 insertions(+), 19 deletions(-) create mode 100644 bin/configs/powershell-echo-api.yaml create mode 100644 samples/client/echo_api/powershell/.openapi-generator-ignore create mode 100644 samples/client/echo_api/powershell/.openapi-generator/FILES create mode 100644 samples/client/echo_api/powershell/.openapi-generator/VERSION create mode 100644 samples/client/echo_api/powershell/Build.ps1 create mode 100644 samples/client/echo_api/powershell/README.md create mode 100644 samples/client/echo_api/powershell/appveyor.yml create mode 100644 samples/client/echo_api/powershell/docs/AuthApi.md create mode 100644 samples/client/echo_api/powershell/docs/Bird.md create mode 100644 samples/client/echo_api/powershell/docs/BodyApi.md create mode 100644 samples/client/echo_api/powershell/docs/Category.md create mode 100644 samples/client/echo_api/powershell/docs/DataQuery.md create mode 100644 samples/client/echo_api/powershell/docs/DefaultValue.md create mode 100644 samples/client/echo_api/powershell/docs/FormApi.md create mode 100644 samples/client/echo_api/powershell/docs/HeaderApi.md create mode 100644 samples/client/echo_api/powershell/docs/NumberPropertiesOnly.md create mode 100644 samples/client/echo_api/powershell/docs/PathApi.md create mode 100644 samples/client/echo_api/powershell/docs/Pet.md create mode 100644 samples/client/echo_api/powershell/docs/Query.md create mode 100644 samples/client/echo_api/powershell/docs/QueryApi.md create mode 100644 samples/client/echo_api/powershell/docs/StringEnumRef.md create mode 100644 samples/client/echo_api/powershell/docs/Tag.md create mode 100644 samples/client/echo_api/powershell/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md create mode 100644 samples/client/echo_api/powershell/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Api/AuthApi.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Api/BodyApi.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Api/FormApi.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Api/HeaderApi.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Api/PathApi.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Api/QueryApi.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Client/Configuration.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Bird.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Category.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Model/DataQuery.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Model/DefaultValue.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Model/NumberPropertiesOnly.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Pet.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Query.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Model/StringEnumRef.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Tag.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/PSOpenAPITools.psm1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Private/ApiClient.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Private/Get-CommonParameters.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Private/HttpSignatureAuth.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Private/Out-DebugParameter.ps1 create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/Private/RSAEncryptionProvider.cs create mode 100644 samples/client/echo_api/powershell/src/PSOpenAPITools/en-US/about_PSOpenAPITools.help.txt create mode 100644 samples/client/echo_api/powershell/tests/Api/AuthApi.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Api/BodyApi.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Api/FormApi.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Api/HeaderApi.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Api/PathApi.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Api/QueryApi.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Model/Bird.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Model/Category.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Model/DataQuery.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Model/DefaultValue.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Model/NumberPropertiesOnly.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Model/Pet.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Model/Query.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Model/StringEnumRef.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Model/Tag.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.Tests.ps1 create mode 100644 samples/client/echo_api/powershell/tests/Model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.Tests.ps1 diff --git a/bin/configs/powershell-echo-api.yaml b/bin/configs/powershell-echo-api.yaml new file mode 100644 index 000000000000..2bf9c383c17a --- /dev/null +++ b/bin/configs/powershell-echo-api.yaml @@ -0,0 +1,7 @@ +generatorName: powershell +outputDir: samples/client/echo_api/powershell +inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml +templateDir: modules/openapi-generator/src/main/resources/powershell +additionalProperties: + hideGenerationTimestamp: "true" + packageGuid: a27b908d-2a20-467f-bc32-af6f3a654ac5 diff --git a/modules/openapi-generator/src/test/resources/3_0/powershell/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/powershell/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index aecc1b8d4473..ff6dc25960f3 100644 --- a/modules/openapi-generator/src/test/resources/3_0/powershell/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/powershell/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -1206,11 +1206,11 @@ components: 'read:pets': read your pets api_key: type: apiKey - name: api_key + name: api_key_name in: header api_key_query: type: apiKey - name: api_key_query + name: api_key_query_name in: query http_basic_test: type: http diff --git a/samples/client/echo_api/powershell/.openapi-generator-ignore b/samples/client/echo_api/powershell/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/echo_api/powershell/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/echo_api/powershell/.openapi-generator/FILES b/samples/client/echo_api/powershell/.openapi-generator/FILES new file mode 100644 index 000000000000..109ec0237363 --- /dev/null +++ b/samples/client/echo_api/powershell/.openapi-generator/FILES @@ -0,0 +1,45 @@ +Build.ps1 +README.md +appveyor.yml +docs/AuthApi.md +docs/Bird.md +docs/BodyApi.md +docs/Category.md +docs/DataQuery.md +docs/DefaultValue.md +docs/FormApi.md +docs/HeaderApi.md +docs/NumberPropertiesOnly.md +docs/PathApi.md +docs/Pet.md +docs/Query.md +docs/QueryApi.md +docs/StringEnumRef.md +docs/Tag.md +docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md +docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md +src/PSOpenAPITools/Api/AuthApi.ps1 +src/PSOpenAPITools/Api/BodyApi.ps1 +src/PSOpenAPITools/Api/FormApi.ps1 +src/PSOpenAPITools/Api/HeaderApi.ps1 +src/PSOpenAPITools/Api/PathApi.ps1 +src/PSOpenAPITools/Api/QueryApi.ps1 +src/PSOpenAPITools/Client/Configuration.ps1 +src/PSOpenAPITools/Model/Bird.ps1 +src/PSOpenAPITools/Model/Category.ps1 +src/PSOpenAPITools/Model/DataQuery.ps1 +src/PSOpenAPITools/Model/DefaultValue.ps1 +src/PSOpenAPITools/Model/NumberPropertiesOnly.ps1 +src/PSOpenAPITools/Model/Pet.ps1 +src/PSOpenAPITools/Model/Query.ps1 +src/PSOpenAPITools/Model/StringEnumRef.ps1 +src/PSOpenAPITools/Model/Tag.ps1 +src/PSOpenAPITools/Model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.ps1 +src/PSOpenAPITools/Model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.ps1 +src/PSOpenAPITools/PSOpenAPITools.psm1 +src/PSOpenAPITools/Private/ApiClient.ps1 +src/PSOpenAPITools/Private/Get-CommonParameters.ps1 +src/PSOpenAPITools/Private/HttpSignatureAuth.ps1 +src/PSOpenAPITools/Private/Out-DebugParameter.ps1 +src/PSOpenAPITools/Private/RSAEncryptionProvider.cs +src/PSOpenAPITools/en-US/about_PSOpenAPITools.help.txt diff --git a/samples/client/echo_api/powershell/.openapi-generator/VERSION b/samples/client/echo_api/powershell/.openapi-generator/VERSION new file mode 100644 index 000000000000..40e36364ab27 --- /dev/null +++ b/samples/client/echo_api/powershell/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.1.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/echo_api/powershell/Build.ps1 b/samples/client/echo_api/powershell/Build.ps1 new file mode 100644 index 000000000000..49d6a3a92745 --- /dev/null +++ b/samples/client/echo_api/powershell/Build.ps1 @@ -0,0 +1,73 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +function Get-FunctionsToExport { + [CmdletBinding()] + Param ( + [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [Alias('FullName')] + $Path + ) + + Process { + $Token = $null + $ParserErr = $null + + $Ast = [System.Management.Automation.Language.Parser]::ParseFile( + $Path, + [ref]$Token, + [ref]$ParserErr + ) + + if ($ParserErr) { + throw $ParserErr + } else { + foreach ($name in 'Begin', 'Process', 'End') { + foreach ($Statement in $Ast."${name}Block".Statements) { + if ( + [String]::IsNullOrWhiteSpace($Statement.Name) -or + $Statement.Extent.ToString() -notmatch + ('function\W+{0}' -f $Statement.Name) + ) { + continue + } + + $Statement.Name + } + } + } + } +} + +$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path +$FunctionPath = 'Api', 'Model', 'Client' | ForEach-Object {Join-Path "$ScriptDir\src\PSOpenAPITools\" $_} + +$Manifest = @{ + Path = "$ScriptDir\src\PSOpenAPITools\PSOpenAPITools.psd1" + + Author = 'OpenAPI Generator Team' + CompanyName = 'openapitools.org' + Description = 'PSOpenAPITools - the PowerShell module for Echo Server API' + + ModuleVersion = '0.1.2' + + RootModule = 'PSOpenAPITools.psm1' + Guid = 'a27b908d-2a20-467f-bc32-af6f3a654ac5' # Has to be static, otherwise each new build will be considered different module + + PowerShellVersion = '6.2' + + FunctionsToExport = $FunctionPath | Get-ChildItem -Filter *.ps1 | Get-FunctionsToExport + + VariablesToExport = @() + AliasesToExport = @() + CmdletsToExport = @() + +} + +New-ModuleManifest @Manifest diff --git a/samples/client/echo_api/powershell/README.md b/samples/client/echo_api/powershell/README.md new file mode 100644 index 000000000000..0ef000a4ecc2 --- /dev/null +++ b/samples/client/echo_api/powershell/README.md @@ -0,0 +1,102 @@ +# PSOpenAPITools - the PowerShell module for the Echo Server API + +Echo Server API + +This PowerShell module is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: 0.1.0 +- SDK version: 0.1.2 +- Build package: org.openapitools.codegen.languages.PowerShellClientCodegen + + +## Frameworks supported +- PowerShell 6.2 or later + + +## Dependencies + + +## Installation + + +To install from the source, run the following command to build and install the PowerShell module locally: +```powershell +Build.ps1 +Import-Module -Name '.\src\PSOpenAPITools' -Verbose +``` + +To avoid function name collision, one can use `-Prefix`, e.g. `Import-Module -Name '.\src\PSOpenAPITools' -Prefix prefix` + +To uninstall the module, simply run: +```powershell +Remove-Module -FullyQualifiedName @{ModuleName = "PSOpenAPITools"; ModuleVersion = "0.1.2"} +``` + + +## Tests + +To install and run `Pester`, please execute the following commands in the terminal: + +```powershell +Install-module -name Pester -force + +Invoke-Pester +``` + +For troubleshooting, please run `$DebugPreference = 'Continue'` to turn on debugging and disable it with `$DebugPreference = 'SilentlyContinue'` when done with the troubleshooting. + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost:3000* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*AuthApi* | [**Test-AuthHttpBasic**](docs/AuthApi.md#Test-AuthHttpBasic) | **POST** /auth/http/basic | To test HTTP basic authentication +*BodyApi* | [**Test-BinaryGif**](docs/BodyApi.md#Test-BinaryGif) | **POST** /binary/gif | Test binary (gif) response body +*BodyApi* | [**Test-BodyApplicationOctetstreamBinary**](docs/BodyApi.md#Test-BodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s) +*BodyApi* | [**Test-BodyMultipartFormdataArrayOfBinary**](docs/BodyApi.md#Test-BodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime +*BodyApi* | [**Test-EchoBodyFreeFormObjectResponseString**](docs/BodyApi.md#Test-EchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object +*BodyApi* | [**Test-EchoBodyPet**](docs/BodyApi.md#Test-EchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s) +*BodyApi* | [**Test-EchoBodyPetResponseString**](docs/BodyApi.md#Test-EchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body +*BodyApi* | [**Test-EchoBodyTagResponseString**](docs/BodyApi.md#Test-EchoBodyTagResponseString) | **POST** /echo/body/Tag/response_string | Test empty json (request body) +*BodyApi* | [**Test-EchoBodyAllOfPet**](docs/BodyApi.md#Test-EchoBodyAllOfPet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) +*FormApi* | [**Test-FormIntegerBooleanString**](docs/FormApi.md#Test-FormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s) +*FormApi* | [**Test-FormOneof**](docs/FormApi.md#Test-FormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema +*HeaderApi* | [**Test-HeaderIntegerBooleanStringEnums**](docs/HeaderApi.md#Test-HeaderIntegerBooleanStringEnums) | **GET** /header/integer/boolean/string/enums | Test header parameter(s) +*PathApi* | [**Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath**](docs/PathApi.md#Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath) | **GET** /path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path} | Test path parameter(s) +*QueryApi* | [**Test-EnumRefString**](docs/QueryApi.md#Test-EnumRefString) | **GET** /query/enum_ref_string | Test query parameter(s) +*QueryApi* | [**Test-QueryDatetimeDateString**](docs/QueryApi.md#Test-QueryDatetimeDateString) | **GET** /query/datetime/date/string | Test query parameter(s) +*QueryApi* | [**Test-QueryIntegerBooleanString**](docs/QueryApi.md#Test-QueryIntegerBooleanString) | **GET** /query/integer/boolean/string | Test query parameter(s) +*QueryApi* | [**Test-QueryStyleDeepObjectExplodeTrueObject**](docs/QueryApi.md#Test-QueryStyleDeepObjectExplodeTrueObject) | **GET** /query/style_deepObject/explode_true/object | Test query parameter(s) +*QueryApi* | [**Test-QueryStyleDeepObjectExplodeTrueObjectAllOf**](docs/QueryApi.md#Test-QueryStyleDeepObjectExplodeTrueObjectAllOf) | **GET** /query/style_deepObject/explode_true/object/allOf | Test query parameter(s) +*QueryApi* | [**Test-QueryStyleFormExplodeTrueArrayString**](docs/QueryApi.md#Test-QueryStyleFormExplodeTrueArrayString) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s) +*QueryApi* | [**Test-QueryStyleFormExplodeTrueObject**](docs/QueryApi.md#Test-QueryStyleFormExplodeTrueObject) | **GET** /query/style_form/explode_true/object | Test query parameter(s) +*QueryApi* | [**Test-QueryStyleFormExplodeTrueObjectAllOf**](docs/QueryApi.md#Test-QueryStyleFormExplodeTrueObjectAllOf) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s) + + +## Documentation for Models + + - [PSOpenAPITools\Model.Bird](docs/Bird.md) + - [PSOpenAPITools\Model.Category](docs/Category.md) + - [PSOpenAPITools\Model.DataQuery](docs/DataQuery.md) + - [PSOpenAPITools\Model.DefaultValue](docs/DefaultValue.md) + - [PSOpenAPITools\Model.NumberPropertiesOnly](docs/NumberPropertiesOnly.md) + - [PSOpenAPITools\Model.Pet](docs/Pet.md) + - [PSOpenAPITools\Model.Query](docs/Query.md) + - [PSOpenAPITools\Model.StringEnumRef](docs/StringEnumRef.md) + - [PSOpenAPITools\Model.Tag](docs/Tag.md) + - [PSOpenAPITools\Model.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter](docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md) + - [PSOpenAPITools\Model.TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md) + + + +## Documentation for Authorization + + +Authentication schemes defined for the API: + +### http_auth + + +- **Type**: HTTP basic authentication + diff --git a/samples/client/echo_api/powershell/appveyor.yml b/samples/client/echo_api/powershell/appveyor.yml new file mode 100644 index 000000000000..0df91baedea4 --- /dev/null +++ b/samples/client/echo_api/powershell/appveyor.yml @@ -0,0 +1,41 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +version: 1.0.{build} +image: + - Visual Studio 2019 # PWSH 7.x + #- Visual Studio 2017 # PS 5.x, PWSH 6.x + #- Ubuntu # PWSH 6.x + # ref: https://www.appveyor.com/docs/windows-images-software/ +install: + - pwsh: $PSVersionTable.PSVersion + - pwsh: Install-Module Pester -Force -Scope CurrentUser +build: off +test_script: + - pwsh: | + .\Build.ps1 + Import-Module -Name '.\src\PSOpenAPITools' + $Result = Invoke-Pester -PassThru + if ($Result.FailedCount -gt 0) { + $host.SetShouldExit($Result.FailedCount) + exit $Result.FailedCount + } +deploy_script: + - pwsh: | + if ($env:APPVEYOR_REPO_TAG -eq $true -and $null -ne $env:NuGetApiKey) { + .\Build.ps1 + try { + Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\src\PSOpenAPITools\ -Confirm:$False -Verbose + Write-Host "Successfully published the PowerShell module." + } catch { + $host.SetShouldExit($LastExitCode) + Write-Host "Error when running Publish-Module:" + Write-Host $_ + exit + } + } diff --git a/samples/client/echo_api/powershell/docs/AuthApi.md b/samples/client/echo_api/powershell/docs/AuthApi.md new file mode 100644 index 000000000000..9fabb8c0d6d8 --- /dev/null +++ b/samples/client/echo_api/powershell/docs/AuthApi.md @@ -0,0 +1,53 @@ +# PSOpenAPITools.PSOpenAPITools\Api.AuthApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**Test-AuthHttpBasic**](AuthApi.md#Test-AuthHttpBasic) | **POST** /auth/http/basic | To test HTTP basic authentication + + + +# **Test-AuthHttpBasic** +> String Test-AuthHttpBasic
+ +To test HTTP basic authentication + +To test HTTP basic authentication + +### Example +```powershell +# general setting of the PowerShell module, e.g. base URL, authentication, etc +$Configuration = Get-Configuration +# Configure HTTP basic authorization: http_auth +$Configuration.Username = "YOUR_USERNAME" +$Configuration.Password = "YOUR_PASSWORD" + + +# To test HTTP basic authentication +try { + $Result = Test-AuthHttpBasic +} catch { + Write-Host ("Exception occurred when calling Test-AuthHttpBasic: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**String** + +### Authorization + +[http_auth](../README.md#http_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/Bird.md b/samples/client/echo_api/powershell/docs/Bird.md new file mode 100644 index 000000000000..1f9a67dfe951 --- /dev/null +++ b/samples/client/echo_api/powershell/docs/Bird.md @@ -0,0 +1,23 @@ +# Bird +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Size** | **String** | | [optional] +**Color** | **String** | | [optional] + +## Examples + +- Prepare the resource +```powershell +$Bird = Initialize-PSOpenAPIToolsBird -Size null ` + -Color null +``` + +- Convert the resource to JSON +```powershell +$Bird | ConvertTo-JSON +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/BodyApi.md b/samples/client/echo_api/powershell/docs/BodyApi.md new file mode 100644 index 000000000000..b2c52e663ed8 --- /dev/null +++ b/samples/client/echo_api/powershell/docs/BodyApi.md @@ -0,0 +1,361 @@ +# PSOpenAPITools.PSOpenAPITools\Api.BodyApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**Test-BinaryGif**](BodyApi.md#Test-BinaryGif) | **POST** /binary/gif | Test binary (gif) response body +[**Test-BodyApplicationOctetstreamBinary**](BodyApi.md#Test-BodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s) +[**Test-BodyMultipartFormdataArrayOfBinary**](BodyApi.md#Test-BodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime +[**Test-EchoBodyFreeFormObjectResponseString**](BodyApi.md#Test-EchoBodyFreeFormObjectResponseString) | **POST** /echo/body/FreeFormObject/response_string | Test free form object +[**Test-EchoBodyPet**](BodyApi.md#Test-EchoBodyPet) | **POST** /echo/body/Pet | Test body parameter(s) +[**Test-EchoBodyPetResponseString**](BodyApi.md#Test-EchoBodyPetResponseString) | **POST** /echo/body/Pet/response_string | Test empty response body +[**Test-EchoBodyTagResponseString**](BodyApi.md#Test-EchoBodyTagResponseString) | **POST** /echo/body/Tag/response_string | Test empty json (request body) +[**Test-EchoBodyAllOfPet**](BodyApi.md#Test-EchoBodyAllOfPet) | **POST** /echo/body/allOf/Pet | Test body parameter(s) + + + +# **Test-BinaryGif** +> System.IO.FileInfo Test-BinaryGif
+ +Test binary (gif) response body + +Test binary (gif) response body + +### Example +```powershell + +# Test binary (gif) response body +try { + $Result = Test-BinaryGif +} catch { + Write-Host ("Exception occurred when calling Test-BinaryGif: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**System.IO.FileInfo** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: image/gif + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-BodyApplicationOctetstreamBinary** +> String Test-BodyApplicationOctetstreamBinary
+>         [-Body]
+ +Test body parameter(s) + +Test body parameter(s) + +### Example +```powershell +$Body = # System.IO.FileInfo | (optional) + +# Test body parameter(s) +try { + $Result = Test-BodyApplicationOctetstreamBinary -Body $Body +} catch { + Write-Host ("Exception occurred when calling Test-BodyApplicationOctetstreamBinary: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **Body** | **System.IO.FileInfo****System.IO.FileInfo**| | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/octet-stream + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-BodyMultipartFormdataArrayOfBinary** +> String Test-BodyMultipartFormdataArrayOfBinary
+>         [-Files]
+ +Test array of binary in multipart mime + +Test array of binary in multipart mime + +### Example +```powershell +$Files = # System.IO.FileInfo[] | + +# Test array of binary in multipart mime +try { + $Result = Test-BodyMultipartFormdataArrayOfBinary -Files $Files +} catch { + Write-Host ("Exception occurred when calling Test-BodyMultipartFormdataArrayOfBinary: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **Files** | **System.IO.FileInfo[]**| | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-EchoBodyFreeFormObjectResponseString** +> String Test-EchoBodyFreeFormObjectResponseString
+>         [-Body]
+ +Test free form object + +Test free form object + +### Example +```powershell +$Body = @{ key_example = ... } # SystemCollectionsHashtable | Free form object (optional) + +# Test free form object +try { + $Result = Test-EchoBodyFreeFormObjectResponseString -Body $Body +} catch { + Write-Host ("Exception occurred when calling Test-EchoBodyFreeFormObjectResponseString: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **Body** | **SystemCollectionsHashtable**| Free form object | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-EchoBodyPet** +> Pet Test-EchoBodyPet
+>         [-Pet]
+ +Test body parameter(s) + +Test body parameter(s) + +### Example +```powershell +$Category = Initialize-Category -Id 1 -Name "Dogs" +$Tag = Initialize-Tag -Id 0 -Name "MyName" +$Pet = Initialize-Pet -Id 10 -Name "doggie" -Category $Category -PhotoUrls "MyPhotoUrls" -Tags $Tag -Status "available" # Pet | Pet object that needs to be added to the store (optional) + +# Test body parameter(s) +try { + $Result = Test-EchoBodyPet -Pet $Pet +} catch { + Write-Host ("Exception occurred when calling Test-EchoBodyPet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **Pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +[**Pet**](Pet.md) (PSCustomObject) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-EchoBodyPetResponseString** +> String Test-EchoBodyPetResponseString
+>         [-Pet]
+ +Test empty response body + +Test empty response body + +### Example +```powershell +$Category = Initialize-Category -Id 1 -Name "Dogs" +$Tag = Initialize-Tag -Id 0 -Name "MyName" +$Pet = Initialize-Pet -Id 10 -Name "doggie" -Category $Category -PhotoUrls "MyPhotoUrls" -Tags $Tag -Status "available" # Pet | Pet object that needs to be added to the store (optional) + +# Test empty response body +try { + $Result = Test-EchoBodyPetResponseString -Pet $Pet +} catch { + Write-Host ("Exception occurred when calling Test-EchoBodyPetResponseString: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **Pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-EchoBodyTagResponseString** +> String Test-EchoBodyTagResponseString
+>         [-Tag]
+ +Test empty json (request body) + +Test empty json (request body) + +### Example +```powershell +$Tag = Initialize-Tag -Id 0 -Name "MyName" # Tag | Tag object (optional) + +# Test empty json (request body) +try { + $Result = Test-EchoBodyTagResponseString -Tag $Tag +} catch { + Write-Host ("Exception occurred when calling Test-EchoBodyTagResponseString: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **Tag** | [**Tag**](Tag.md)| Tag object | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-EchoBodyAllOfPet** +> Pet Test-EchoBodyAllOfPet
+>         [-Pet]
+ +Test body parameter(s) + +Test body parameter(s) + +### Example +```powershell +$Category = Initialize-Category -Id 1 -Name "Dogs" +$Tag = Initialize-Tag -Id 0 -Name "MyName" +$Pet = Initialize-Pet -Id 10 -Name "doggie" -Category $Category -PhotoUrls "MyPhotoUrls" -Tags $Tag -Status "available" # Pet | Pet object that needs to be added to the store (optional) + +# Test body parameter(s) +try { + $Result = Test-EchoBodyAllOfPet -Pet $Pet +} catch { + Write-Host ("Exception occurred when calling Test-EchoBodyAllOfPet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **Pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +[**Pet**](Pet.md) (PSCustomObject) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/Category.md b/samples/client/echo_api/powershell/docs/Category.md new file mode 100644 index 000000000000..1d6bc8d56bef --- /dev/null +++ b/samples/client/echo_api/powershell/docs/Category.md @@ -0,0 +1,23 @@ +# Category +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **Int64** | | [optional] +**Name** | **String** | | [optional] + +## Examples + +- Prepare the resource +```powershell +$Category = Initialize-PSOpenAPIToolsCategory -Id 1 ` + -Name Dogs +``` + +- Convert the resource to JSON +```powershell +$Category | ConvertTo-JSON +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/DataQuery.md b/samples/client/echo_api/powershell/docs/DataQuery.md new file mode 100644 index 000000000000..68ac67b59906 --- /dev/null +++ b/samples/client/echo_api/powershell/docs/DataQuery.md @@ -0,0 +1,29 @@ +# DataQuery +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **Int64** | Query | [optional] +**Outcomes** | **String[]** | | [optional] +**Suffix** | **String** | test suffix | [optional] +**Text** | **String** | Some text containing white spaces | [optional] +**Date** | **System.DateTime** | A date | [optional] + +## Examples + +- Prepare the resource +```powershell +$DataQuery = Initialize-PSOpenAPIToolsDataQuery -Id null ` + -Outcomes null ` + -Suffix null ` + -Text Some text ` + -Date null +``` + +- Convert the resource to JSON +```powershell +$DataQuery | ConvertTo-JSON +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/DefaultValue.md b/samples/client/echo_api/powershell/docs/DefaultValue.md new file mode 100644 index 000000000000..6217b0b2e589 --- /dev/null +++ b/samples/client/echo_api/powershell/docs/DefaultValue.md @@ -0,0 +1,35 @@ +# DefaultValue +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ArrayStringEnumRefDefault** | [**StringEnumRef[]**](StringEnumRef.md) | | [optional] +**ArrayStringEnumDefault** | **String[]** | | [optional] +**ArrayStringDefault** | **String[]** | | [optional] +**ArrayIntegerDefault** | **Int32[]** | | [optional] +**ArrayString** | **String[]** | | [optional] +**ArrayStringNullable** | **String[]** | | [optional] +**ArrayStringExtensionNullable** | **String[]** | | [optional] +**StringNullable** | **String** | | [optional] + +## Examples + +- Prepare the resource +```powershell +$DefaultValue = Initialize-PSOpenAPIToolsDefaultValue -ArrayStringEnumRefDefault null ` + -ArrayStringEnumDefault null ` + -ArrayStringDefault null ` + -ArrayIntegerDefault null ` + -ArrayString null ` + -ArrayStringNullable null ` + -ArrayStringExtensionNullable null ` + -StringNullable null +``` + +- Convert the resource to JSON +```powershell +$DefaultValue | ConvertTo-JSON +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/FormApi.md b/samples/client/echo_api/powershell/docs/FormApi.md new file mode 100644 index 000000000000..96b1e233351c --- /dev/null +++ b/samples/client/echo_api/powershell/docs/FormApi.md @@ -0,0 +1,117 @@ +# PSOpenAPITools.PSOpenAPITools\Api.FormApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**Test-FormIntegerBooleanString**](FormApi.md#Test-FormIntegerBooleanString) | **POST** /form/integer/boolean/string | Test form parameter(s) +[**Test-FormOneof**](FormApi.md#Test-FormOneof) | **POST** /form/oneof | Test form parameter(s) for oneOf schema + + + +# **Test-FormIntegerBooleanString** +> String Test-FormIntegerBooleanString
+>         [-IntegerForm]
+>         [-BooleanForm]
+>         [-StringForm]
+ +Test form parameter(s) + +Test form parameter(s) + +### Example +```powershell +$IntegerForm = 56 # Int32 | (optional) +$BooleanForm = $true # Boolean | (optional) +$StringForm = "MyStringForm" # String | (optional) + +# Test form parameter(s) +try { + $Result = Test-FormIntegerBooleanString -IntegerForm $IntegerForm -BooleanForm $BooleanForm -StringForm $StringForm +} catch { + Write-Host ("Exception occurred when calling Test-FormIntegerBooleanString: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **IntegerForm** | **Int32**| | [optional] + **BooleanForm** | **Boolean**| | [optional] + **StringForm** | **String**| | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-FormOneof** +> String Test-FormOneof
+>         [-Form1]
+>         [-Form2]
+>         [-Form3]
+>         [-Form4]
+>         [-Id]
+>         [-Name]
+ +Test form parameter(s) for oneOf schema + +Test form parameter(s) for oneOf schema + +### Example +```powershell +$Form1 = "MyForm1" # String | (optional) +$Form2 = 56 # Int32 | (optional) +$Form3 = "MyForm3" # String | (optional) +$Form4 = $true # Boolean | (optional) +$Id = 789 # Int64 | (optional) +$Name = "MyName" # String | (optional) + +# Test form parameter(s) for oneOf schema +try { + $Result = Test-FormOneof -Form1 $Form1 -Form2 $Form2 -Form3 $Form3 -Form4 $Form4 -Id $Id -Name $Name +} catch { + Write-Host ("Exception occurred when calling Test-FormOneof: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **Form1** | **String**| | [optional] + **Form2** | **Int32**| | [optional] + **Form3** | **String**| | [optional] + **Form4** | **Boolean**| | [optional] + **Id** | **Int64**| | [optional] + **Name** | **String**| | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/HeaderApi.md b/samples/client/echo_api/powershell/docs/HeaderApi.md new file mode 100644 index 000000000000..74b19de21298 --- /dev/null +++ b/samples/client/echo_api/powershell/docs/HeaderApi.md @@ -0,0 +1,64 @@ +# PSOpenAPITools.PSOpenAPITools\Api.HeaderApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**Test-HeaderIntegerBooleanStringEnums**](HeaderApi.md#Test-HeaderIntegerBooleanStringEnums) | **GET** /header/integer/boolean/string/enums | Test header parameter(s) + + + +# **Test-HeaderIntegerBooleanStringEnums** +> String Test-HeaderIntegerBooleanStringEnums
+>         [-IntegerHeader]
+>         [-BooleanHeader]
+>         [-StringHeader]
+>         [-EnumNonrefStringHeader]
+>         [-EnumRefStringHeader]
+ +Test header parameter(s) + +Test header parameter(s) + +### Example +```powershell +$IntegerHeader = 56 # Int32 | (optional) +$BooleanHeader = $true # Boolean | (optional) +$StringHeader = "MyStringHeader" # String | (optional) +$EnumNonrefStringHeader = "success" # String | (optional) +$EnumRefStringHeader = "success" # StringEnumRef | (optional) + +# Test header parameter(s) +try { + $Result = Test-HeaderIntegerBooleanStringEnums -IntegerHeader $IntegerHeader -BooleanHeader $BooleanHeader -StringHeader $StringHeader -EnumNonrefStringHeader $EnumNonrefStringHeader -EnumRefStringHeader $EnumRefStringHeader +} catch { + Write-Host ("Exception occurred when calling Test-HeaderIntegerBooleanStringEnums: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **IntegerHeader** | **Int32**| | [optional] + **BooleanHeader** | **Boolean**| | [optional] + **StringHeader** | **String**| | [optional] + **EnumNonrefStringHeader** | **String**| | [optional] + **EnumRefStringHeader** | [**StringEnumRef**](StringEnumRef.md)| | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/NumberPropertiesOnly.md b/samples/client/echo_api/powershell/docs/NumberPropertiesOnly.md new file mode 100644 index 000000000000..155a209a85af --- /dev/null +++ b/samples/client/echo_api/powershell/docs/NumberPropertiesOnly.md @@ -0,0 +1,25 @@ +# NumberPropertiesOnly +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Number** | **Decimal** | | [optional] +**Float** | **Double** | | [optional] +**Double** | **Double** | | [optional] + +## Examples + +- Prepare the resource +```powershell +$NumberPropertiesOnly = Initialize-PSOpenAPIToolsNumberPropertiesOnly -Number null ` + -Float null ` + -Double null +``` + +- Convert the resource to JSON +```powershell +$NumberPropertiesOnly | ConvertTo-JSON +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/PathApi.md b/samples/client/echo_api/powershell/docs/PathApi.md new file mode 100644 index 000000000000..1ee5292fd84a --- /dev/null +++ b/samples/client/echo_api/powershell/docs/PathApi.md @@ -0,0 +1,61 @@ +# PSOpenAPITools.PSOpenAPITools\Api.PathApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath**](PathApi.md#Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath) | **GET** /path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path} | Test path parameter(s) + + + +# **Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath** +> String Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath
+>         [-PathString]
+>         [-PathInteger]
+>         [-EnumNonrefStringPath]
+>         [-EnumRefStringPath]
+ +Test path parameter(s) + +Test path parameter(s) + +### Example +```powershell +$PathString = "MyPathString" # String | +$PathInteger = 56 # Int32 | +$EnumNonrefStringPath = "success" # String | +$EnumRefStringPath = "success" # StringEnumRef | + +# Test path parameter(s) +try { + $Result = Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath -PathString $PathString -PathInteger $PathInteger -EnumNonrefStringPath $EnumNonrefStringPath -EnumRefStringPath $EnumRefStringPath +} catch { + Write-Host ("Exception occurred when calling Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **PathString** | **String**| | + **PathInteger** | **Int32**| | + **EnumNonrefStringPath** | **String**| | + **EnumRefStringPath** | [**StringEnumRef**](StringEnumRef.md)| | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/Pet.md b/samples/client/echo_api/powershell/docs/Pet.md new file mode 100644 index 000000000000..5839d09c86dc --- /dev/null +++ b/samples/client/echo_api/powershell/docs/Pet.md @@ -0,0 +1,31 @@ +# Pet +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **Int64** | | [optional] +**Name** | **String** | | +**Category** | [**Category**](Category.md) | | [optional] +**PhotoUrls** | **String[]** | | +**Tags** | [**Tag[]**](Tag.md) | | [optional] +**Status** | **String** | pet status in the store | [optional] + +## Examples + +- Prepare the resource +```powershell +$Pet = Initialize-PSOpenAPIToolsPet -Id 10 ` + -Name doggie ` + -Category null ` + -PhotoUrls null ` + -Tags null ` + -Status null +``` + +- Convert the resource to JSON +```powershell +$Pet | ConvertTo-JSON +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/Query.md b/samples/client/echo_api/powershell/docs/Query.md new file mode 100644 index 000000000000..b4b02112afb5 --- /dev/null +++ b/samples/client/echo_api/powershell/docs/Query.md @@ -0,0 +1,23 @@ +# Query +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **Int64** | Query | [optional] +**Outcomes** | **String[]** | | [optional] + +## Examples + +- Prepare the resource +```powershell +$Query = Initialize-PSOpenAPIToolsQuery -Id null ` + -Outcomes null +``` + +- Convert the resource to JSON +```powershell +$Query | ConvertTo-JSON +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/QueryApi.md b/samples/client/echo_api/powershell/docs/QueryApi.md new file mode 100644 index 000000000000..0af0d6193910 --- /dev/null +++ b/samples/client/echo_api/powershell/docs/QueryApi.md @@ -0,0 +1,379 @@ +# PSOpenAPITools.PSOpenAPITools\Api.QueryApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**Test-EnumRefString**](QueryApi.md#Test-EnumRefString) | **GET** /query/enum_ref_string | Test query parameter(s) +[**Test-QueryDatetimeDateString**](QueryApi.md#Test-QueryDatetimeDateString) | **GET** /query/datetime/date/string | Test query parameter(s) +[**Test-QueryIntegerBooleanString**](QueryApi.md#Test-QueryIntegerBooleanString) | **GET** /query/integer/boolean/string | Test query parameter(s) +[**Test-QueryStyleDeepObjectExplodeTrueObject**](QueryApi.md#Test-QueryStyleDeepObjectExplodeTrueObject) | **GET** /query/style_deepObject/explode_true/object | Test query parameter(s) +[**Test-QueryStyleDeepObjectExplodeTrueObjectAllOf**](QueryApi.md#Test-QueryStyleDeepObjectExplodeTrueObjectAllOf) | **GET** /query/style_deepObject/explode_true/object/allOf | Test query parameter(s) +[**Test-QueryStyleFormExplodeTrueArrayString**](QueryApi.md#Test-QueryStyleFormExplodeTrueArrayString) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s) +[**Test-QueryStyleFormExplodeTrueObject**](QueryApi.md#Test-QueryStyleFormExplodeTrueObject) | **GET** /query/style_form/explode_true/object | Test query parameter(s) +[**Test-QueryStyleFormExplodeTrueObjectAllOf**](QueryApi.md#Test-QueryStyleFormExplodeTrueObjectAllOf) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s) + + + +# **Test-EnumRefString** +> String Test-EnumRefString
+>         [-EnumNonrefStringQuery]
+>         [-EnumRefStringQuery]
+ +Test query parameter(s) + +Test query parameter(s) + +### Example +```powershell +$EnumNonrefStringQuery = "success" # String | (optional) +$EnumRefStringQuery = "success" # StringEnumRef | (optional) + +# Test query parameter(s) +try { + $Result = Test-EnumRefString -EnumNonrefStringQuery $EnumNonrefStringQuery -EnumRefStringQuery $EnumRefStringQuery +} catch { + Write-Host ("Exception occurred when calling Test-EnumRefString: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **EnumNonrefStringQuery** | **String**| | [optional] + **EnumRefStringQuery** | [**StringEnumRef**](StringEnumRef.md)| | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-QueryDatetimeDateString** +> String Test-QueryDatetimeDateString
+>         [-DatetimeQuery]
+>         [-DateQuery]
+>         [-StringQuery]
+ +Test query parameter(s) + +Test query parameter(s) + +### Example +```powershell +$DatetimeQuery = (Get-Date) # System.DateTime | (optional) +$DateQuery = (Get-Date) # System.DateTime | (optional) +$StringQuery = "MyStringQuery" # String | (optional) + +# Test query parameter(s) +try { + $Result = Test-QueryDatetimeDateString -DatetimeQuery $DatetimeQuery -DateQuery $DateQuery -StringQuery $StringQuery +} catch { + Write-Host ("Exception occurred when calling Test-QueryDatetimeDateString: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **DatetimeQuery** | **System.DateTime**| | [optional] + **DateQuery** | **System.DateTime**| | [optional] + **StringQuery** | **String**| | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-QueryIntegerBooleanString** +> String Test-QueryIntegerBooleanString
+>         [-IntegerQuery]
+>         [-BooleanQuery]
+>         [-StringQuery]
+ +Test query parameter(s) + +Test query parameter(s) + +### Example +```powershell +$IntegerQuery = 56 # Int32 | (optional) +$BooleanQuery = $true # Boolean | (optional) +$StringQuery = "MyStringQuery" # String | (optional) + +# Test query parameter(s) +try { + $Result = Test-QueryIntegerBooleanString -IntegerQuery $IntegerQuery -BooleanQuery $BooleanQuery -StringQuery $StringQuery +} catch { + Write-Host ("Exception occurred when calling Test-QueryIntegerBooleanString: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **IntegerQuery** | **Int32**| | [optional] + **BooleanQuery** | **Boolean**| | [optional] + **StringQuery** | **String**| | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-QueryStyleDeepObjectExplodeTrueObject** +> String Test-QueryStyleDeepObjectExplodeTrueObject
+>         [-QueryObject]
+ +Test query parameter(s) + +Test query parameter(s) + +### Example +```powershell +$Category = Initialize-Category -Id 1 -Name "Dogs" +$Tag = Initialize-Tag -Id 0 -Name "MyName" +$Pet = Initialize-Pet -Id 10 -Name "doggie" -Category $Category -PhotoUrls "MyPhotoUrls" -Tags $Tag -Status "available" # Pet | (optional) + +# Test query parameter(s) +try { + $Result = Test-QueryStyleDeepObjectExplodeTrueObject -QueryObject $QueryObject +} catch { + Write-Host ("Exception occurred when calling Test-QueryStyleDeepObjectExplodeTrueObject: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **QueryObject** | [**Pet**](Pet.md)| | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-QueryStyleDeepObjectExplodeTrueObjectAllOf** +> String Test-QueryStyleDeepObjectExplodeTrueObjectAllOf
+>         [-QueryObject]
+ +Test query parameter(s) + +Test query parameter(s) + +### Example +```powershell +$TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter = Initialize-TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter -Size "MySize" -Color "MyColor" -Id 1 -Name "Dogs" # TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter | (optional) + +# Test query parameter(s) +try { + $Result = Test-QueryStyleDeepObjectExplodeTrueObjectAllOf -QueryObject $QueryObject +} catch { + Write-Host ("Exception occurred when calling Test-QueryStyleDeepObjectExplodeTrueObjectAllOf: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **QueryObject** | [**TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter**](TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md)| | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-QueryStyleFormExplodeTrueArrayString** +> String Test-QueryStyleFormExplodeTrueArrayString
+>         [-QueryObject]
+ +Test query parameter(s) + +Test query parameter(s) + +### Example +```powershell +$TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter = Initialize-TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter -Values "MyValues" # TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter | (optional) + +# Test query parameter(s) +try { + $Result = Test-QueryStyleFormExplodeTrueArrayString -QueryObject $QueryObject +} catch { + Write-Host ("Exception occurred when calling Test-QueryStyleFormExplodeTrueArrayString: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **QueryObject** | [**TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter**](TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md)| | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-QueryStyleFormExplodeTrueObject** +> String Test-QueryStyleFormExplodeTrueObject
+>         [-QueryObject]
+ +Test query parameter(s) + +Test query parameter(s) + +### Example +```powershell +$Category = Initialize-Category -Id 1 -Name "Dogs" +$Tag = Initialize-Tag -Id 0 -Name "MyName" +$Pet = Initialize-Pet -Id 10 -Name "doggie" -Category $Category -PhotoUrls "MyPhotoUrls" -Tags $Tag -Status "available" # Pet | (optional) + +# Test query parameter(s) +try { + $Result = Test-QueryStyleFormExplodeTrueObject -QueryObject $QueryObject +} catch { + Write-Host ("Exception occurred when calling Test-QueryStyleFormExplodeTrueObject: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **QueryObject** | [**Pet**](Pet.md)| | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **Test-QueryStyleFormExplodeTrueObjectAllOf** +> String Test-QueryStyleFormExplodeTrueObjectAllOf
+>         [-QueryObject]
+ +Test query parameter(s) + +Test query parameter(s) + +### Example +```powershell +"SUCCESS"$DataQuery = Initialize-DataQuery -Id 0 -Outcomes "SUCCESS" -Suffix "MySuffix" -Text "Some text" -Date (Get-Date) # DataQuery | (optional) + +# Test query parameter(s) +try { + $Result = Test-QueryStyleFormExplodeTrueObjectAllOf -QueryObject $QueryObject +} catch { + Write-Host ("Exception occurred when calling Test-QueryStyleFormExplodeTrueObjectAllOf: {0}" -f ($_.ErrorDetails | ConvertFrom-Json)) + Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json)) +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **QueryObject** | [**DataQuery**](DataQuery.md)| | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/StringEnumRef.md b/samples/client/echo_api/powershell/docs/StringEnumRef.md new file mode 100644 index 000000000000..0366f951001c --- /dev/null +++ b/samples/client/echo_api/powershell/docs/StringEnumRef.md @@ -0,0 +1,20 @@ +# StringEnumRef +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Examples + +- Prepare the resource +```powershell +$StringEnumRef = Initialize-PSOpenAPIToolsStringEnumRef +``` + +- Convert the resource to JSON +```powershell +$StringEnumRef | ConvertTo-JSON +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/Tag.md b/samples/client/echo_api/powershell/docs/Tag.md new file mode 100644 index 000000000000..7f7ef9fbb883 --- /dev/null +++ b/samples/client/echo_api/powershell/docs/Tag.md @@ -0,0 +1,23 @@ +# Tag +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **Int64** | | [optional] +**Name** | **String** | | [optional] + +## Examples + +- Prepare the resource +```powershell +$Tag = Initialize-PSOpenAPIToolsTag -Id null ` + -Name null +``` + +- Convert the resource to JSON +```powershell +$Tag | ConvertTo-JSON +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md b/samples/client/echo_api/powershell/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md new file mode 100644 index 000000000000..b854fd2b9e65 --- /dev/null +++ b/samples/client/echo_api/powershell/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md @@ -0,0 +1,27 @@ +# TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Size** | **String** | | [optional] +**Color** | **String** | | [optional] +**Id** | **Int64** | | [optional] +**Name** | **String** | | [optional] + +## Examples + +- Prepare the resource +```powershell +$TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter = Initialize-PSOpenAPIToolsTestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter -Size null ` + -Color null ` + -Id 1 ` + -Name Dogs +``` + +- Convert the resource to JSON +```powershell +$TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter | ConvertTo-JSON +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md b/samples/client/echo_api/powershell/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md new file mode 100644 index 000000000000..96c091c3b0fe --- /dev/null +++ b/samples/client/echo_api/powershell/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md @@ -0,0 +1,21 @@ +# TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Values** | **String[]** | | [optional] + +## Examples + +- Prepare the resource +```powershell +$TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter = Initialize-PSOpenAPIToolsTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter -Values null +``` + +- Convert the resource to JSON +```powershell +$TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter | ConvertTo-JSON +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/AuthApi.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/AuthApi.ps1 new file mode 100644 index 000000000000..3c3888e4e4e4 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/AuthApi.ps1 @@ -0,0 +1,78 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +To test HTTP basic authentication + +.DESCRIPTION + +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-AuthHttpBasic { + [CmdletBinding()] + Param ( + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-AuthHttpBasic' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + $LocalVarUri = '/auth/http/basic' + + if ($Configuration["Username"] -and $Configuration["Password"]) { + $LocalVarBytes = [System.Text.Encoding]::UTF8.GetBytes($Configuration["Username"] + ":" + $Configuration["Password"]) + $LocalVarBase64Text =[Convert]::ToBase64String($LocalVarBytes) + $LocalVarHeaderParameters['Authorization'] = "Basic " + $LocalVarBase64Text + Write-Verbose ("Using HTTP basic authentication in {0}" -f $MyInvocation.MyCommand) + } + + $LocalVarResult = Invoke-ApiClient -Method 'POST' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/BodyApi.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/BodyApi.ps1 new file mode 100644 index 000000000000..4ddf81d79486 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/BodyApi.ps1 @@ -0,0 +1,592 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +Test binary (gif) response body + +.DESCRIPTION + +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +System.IO.FileInfo +#> +function Test-BinaryGif { + [CmdletBinding()] + Param ( + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-BinaryGif' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('image/gif') + + $LocalVarUri = '/binary/gif' + + $LocalVarResult = Invoke-ApiClient -Method 'POST' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "System.IO.FileInfo" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test body parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER Body +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-BodyApplicationOctetstreamBinary { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.IO.FileInfo] + ${Body}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-BodyApplicationOctetstreamBinary' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + # HTTP header 'Content-Type' + $LocalVarContentTypes = @('application/octet-stream') + + $LocalVarUri = '/body/application/octetstream/binary' + + $LocalVarBodyParameter = $Body | ConvertTo-Json -Depth 100 + + $LocalVarResult = Invoke-ApiClient -Method 'POST' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test array of binary in multipart mime + +.DESCRIPTION + +No description available. + +.PARAMETER Files +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-BodyMultipartFormdataArrayOfBinary { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.IO.FileInfo[]] + ${Files}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-BodyMultipartFormdataArrayOfBinary' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + # HTTP header 'Content-Type' + $LocalVarContentTypes = @('multipart/form-data') + + $LocalVarUri = '/body/application/octetstream/array_of_binary' + + if (!$Files) { + throw "Error! The required parameter `Files` missing when calling test_body_multipart_formdata_arrayOfBinary." + } + $LocalVarFormParameters['files'] = $Files + + $LocalVarResult = Invoke-ApiClient -Method 'POST' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test free form object + +.DESCRIPTION + +No description available. + +.PARAMETER Body +Free form object + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-EchoBodyFreeFormObjectResponseString { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.Nullable[SystemCollectionsHashtable]] + ${Body}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-EchoBodyFreeFormObjectResponseString' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + # HTTP header 'Content-Type' + $LocalVarContentTypes = @('application/json') + + $LocalVarUri = '/echo/body/FreeFormObject/response_string' + + $LocalVarBodyParameter = $Body | ConvertTo-Json -Depth 100 + + $LocalVarResult = Invoke-ApiClient -Method 'POST' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test body parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER Pet +Pet object that needs to be added to the store + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +Pet +#> +function Test-EchoBodyPet { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [PSCustomObject] + ${Pet}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-EchoBodyPet' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('application/json') + + # HTTP header 'Content-Type' + $LocalVarContentTypes = @('application/json') + + $LocalVarUri = '/echo/body/Pet' + + $LocalVarBodyParameter = $Pet | ConvertTo-Json -Depth 100 + + $LocalVarResult = Invoke-ApiClient -Method 'POST' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "Pet" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test empty response body + +.DESCRIPTION + +No description available. + +.PARAMETER Pet +Pet object that needs to be added to the store + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-EchoBodyPetResponseString { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [PSCustomObject] + ${Pet}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-EchoBodyPetResponseString' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + # HTTP header 'Content-Type' + $LocalVarContentTypes = @('application/json') + + $LocalVarUri = '/echo/body/Pet/response_string' + + $LocalVarBodyParameter = $Pet | ConvertTo-Json -Depth 100 + + $LocalVarResult = Invoke-ApiClient -Method 'POST' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test empty json (request body) + +.DESCRIPTION + +No description available. + +.PARAMETER Tag +Tag object + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-EchoBodyTagResponseString { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [PSCustomObject] + ${Tag}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-EchoBodyTagResponseString' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + # HTTP header 'Content-Type' + $LocalVarContentTypes = @('application/json') + + $LocalVarUri = '/echo/body/Tag/response_string' + + $LocalVarBodyParameter = $Tag | ConvertTo-Json -Depth 100 + + $LocalVarResult = Invoke-ApiClient -Method 'POST' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test body parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER Pet +Pet object that needs to be added to the store + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +Pet +#> +function Test-EchoBodyAllOfPet { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [PSCustomObject] + ${Pet}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-EchoBodyAllOfPet' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('application/json') + + # HTTP header 'Content-Type' + $LocalVarContentTypes = @('application/json') + + $LocalVarUri = '/echo/body/allOf/Pet' + + $LocalVarBodyParameter = $Pet | ConvertTo-Json -Depth 100 + + $LocalVarResult = Invoke-ApiClient -Method 'POST' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "Pet" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/FormApi.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/FormApi.ps1 new file mode 100644 index 000000000000..677221d160f7 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/FormApi.ps1 @@ -0,0 +1,230 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +Test form parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER IntegerForm +No description available. + +.PARAMETER BooleanForm +No description available. + +.PARAMETER StringForm +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-FormIntegerBooleanString { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.Nullable[Int32]] + ${IntegerForm}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.Nullable[Boolean]] + ${BooleanForm}, + [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [String] + ${StringForm}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-FormIntegerBooleanString' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + # HTTP header 'Content-Type' + $LocalVarContentTypes = @('application/x-www-form-urlencoded') + + $LocalVarUri = '/form/integer/boolean/string' + + if ($IntegerForm) { + $LocalVarFormParameters['integer_form'] = $IntegerForm + } + + if ($BooleanForm) { + $LocalVarFormParameters['boolean_form'] = $BooleanForm + } + + if ($StringForm) { + $LocalVarFormParameters['string_form'] = $StringForm + } + + $LocalVarResult = Invoke-ApiClient -Method 'POST' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test form parameter(s) for oneOf schema + +.DESCRIPTION + +No description available. + +.PARAMETER Form1 +No description available. + +.PARAMETER Form2 +No description available. + +.PARAMETER Form3 +No description available. + +.PARAMETER Form4 +No description available. + +.PARAMETER Id +No description available. + +.PARAMETER Name +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-FormOneof { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [String] + ${Form1}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.Nullable[Int32]] + ${Form2}, + [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [String] + ${Form3}, + [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.Nullable[Boolean]] + ${Form4}, + [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.Nullable[Int64]] + ${Id}, + [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [String] + ${Name}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-FormOneof' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + # HTTP header 'Content-Type' + $LocalVarContentTypes = @('application/x-www-form-urlencoded') + + $LocalVarUri = '/form/oneof' + + if ($Form1) { + $LocalVarFormParameters['form1'] = $Form1 + } + + if ($Form2) { + $LocalVarFormParameters['form2'] = $Form2 + } + + if ($Form3) { + $LocalVarFormParameters['form3'] = $Form3 + } + + if ($Form4) { + $LocalVarFormParameters['form4'] = $Form4 + } + + if ($Id) { + $LocalVarFormParameters['id'] = $Id + } + + if ($Name) { + $LocalVarFormParameters['name'] = $Name + } + + $LocalVarResult = Invoke-ApiClient -Method 'POST' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/HeaderApi.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/HeaderApi.ps1 new file mode 100644 index 000000000000..73e5c3da98e3 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/HeaderApi.ps1 @@ -0,0 +1,122 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +Test header parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER IntegerHeader +No description available. + +.PARAMETER BooleanHeader +No description available. + +.PARAMETER StringHeader +No description available. + +.PARAMETER EnumNonrefStringHeader +No description available. + +.PARAMETER EnumRefStringHeader +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-HeaderIntegerBooleanStringEnums { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.Nullable[Int32]] + ${IntegerHeader}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.Nullable[Boolean]] + ${BooleanHeader}, + [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [String] + ${StringHeader}, + [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [ValidateSet("success", "failure", "unclassified")] + [String] + ${EnumNonrefStringHeader}, + [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [PSCustomObject] + ${EnumRefStringHeader}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-HeaderIntegerBooleanStringEnums' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + $LocalVarUri = '/header/integer/boolean/string/enums' + + if ($IntegerHeader) { + $LocalVarHeaderParameters['integer_header'] = $IntegerHeader + } + + if ($BooleanHeader) { + $LocalVarHeaderParameters['boolean_header'] = $BooleanHeader + } + + if ($StringHeader) { + $LocalVarHeaderParameters['string_header'] = $StringHeader + } + + if ($EnumNonrefStringHeader) { + $LocalVarHeaderParameters['enum_nonref_string_header'] = $EnumNonrefStringHeader + } + + if ($EnumRefStringHeader) { + $LocalVarHeaderParameters['enum_ref_string_header'] = $EnumRefStringHeader + } + + $LocalVarResult = Invoke-ApiClient -Method 'GET' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/PathApi.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/PathApi.ps1 new file mode 100644 index 000000000000..1eb5d3453b65 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/PathApi.ps1 @@ -0,0 +1,112 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +Test path parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER PathString +No description available. + +.PARAMETER PathInteger +No description available. + +.PARAMETER EnumNonrefStringPath +No description available. + +.PARAMETER EnumRefStringPath +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [String] + ${PathString}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [Int32] + ${PathInteger}, + [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [ValidateSet("success", "failure", "unclassified")] + [String] + ${EnumNonrefStringPath}, + [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [PSCustomObject] + ${EnumRefStringPath}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + $LocalVarUri = '/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}' + if (!$PathString) { + throw "Error! The required parameter `PathString` missing when calling tests_path_string_pathString_integer_pathInteger_enumNonrefStringPath_enumRefStringPath." + } + $LocalVarUri = $LocalVarUri.replace('{path_string}', [System.Web.HTTPUtility]::UrlEncode($PathString)) + if (!$PathInteger) { + throw "Error! The required parameter `PathInteger` missing when calling tests_path_string_pathString_integer_pathInteger_enumNonrefStringPath_enumRefStringPath." + } + $LocalVarUri = $LocalVarUri.replace('{path_integer}', [System.Web.HTTPUtility]::UrlEncode($PathInteger)) + if (!$EnumNonrefStringPath) { + throw "Error! The required parameter `EnumNonrefStringPath` missing when calling tests_path_string_pathString_integer_pathInteger_enumNonrefStringPath_enumRefStringPath." + } + $LocalVarUri = $LocalVarUri.replace('{enum_nonref_string_path}', [System.Web.HTTPUtility]::UrlEncode($EnumNonrefStringPath)) + if (!$EnumRefStringPath) { + throw "Error! The required parameter `EnumRefStringPath` missing when calling tests_path_string_pathString_integer_pathInteger_enumNonrefStringPath_enumRefStringPath." + } + $LocalVarUri = $LocalVarUri.replace('{enum_ref_string_path}', [System.Web.HTTPUtility]::UrlEncode($EnumRefStringPath)) + + $LocalVarResult = Invoke-ApiClient -Method 'GET' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/QueryApi.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/QueryApi.ps1 new file mode 100644 index 000000000000..13bc99c15f46 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Api/QueryApi.ps1 @@ -0,0 +1,643 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +Test query parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER EnumNonrefStringQuery +No description available. + +.PARAMETER EnumRefStringQuery +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-EnumRefString { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [ValidateSet("success", "failure", "unclassified")] + [String] + ${EnumNonrefStringQuery}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [PSCustomObject] + ${EnumRefStringQuery}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-EnumRefString' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + $LocalVarUri = '/query/enum_ref_string' + + if ($EnumNonrefStringQuery) { + $LocalVarQueryParameters['enum_nonref_string_query'] = $EnumNonrefStringQuery + } + + if ($EnumRefStringQuery) { + $LocalVarQueryParameters['enum_ref_string_query'] = $EnumRefStringQuery + } + + $LocalVarResult = Invoke-ApiClient -Method 'GET' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test query parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER DatetimeQuery +No description available. + +.PARAMETER DateQuery +No description available. + +.PARAMETER StringQuery +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-QueryDatetimeDateString { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.Nullable[System.DateTime]] + ${DatetimeQuery}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.Nullable[System.DateTime]] + ${DateQuery}, + [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [String] + ${StringQuery}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-QueryDatetimeDateString' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + $LocalVarUri = '/query/datetime/date/string' + + if ($DatetimeQuery) { + $LocalVarQueryParameters['datetime_query'] = $DatetimeQuery + } + + if ($DateQuery) { + $LocalVarQueryParameters['date_query'] = $DateQuery + } + + if ($StringQuery) { + $LocalVarQueryParameters['string_query'] = $StringQuery + } + + $LocalVarResult = Invoke-ApiClient -Method 'GET' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test query parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER IntegerQuery +No description available. + +.PARAMETER BooleanQuery +No description available. + +.PARAMETER StringQuery +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-QueryIntegerBooleanString { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.Nullable[Int32]] + ${IntegerQuery}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [System.Nullable[Boolean]] + ${BooleanQuery}, + [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [String] + ${StringQuery}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-QueryIntegerBooleanString' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + $LocalVarUri = '/query/integer/boolean/string' + + if ($IntegerQuery) { + $LocalVarQueryParameters['integer_query'] = $IntegerQuery + } + + if ($BooleanQuery) { + $LocalVarQueryParameters['boolean_query'] = $BooleanQuery + } + + if ($StringQuery) { + $LocalVarQueryParameters['string_query'] = $StringQuery + } + + $LocalVarResult = Invoke-ApiClient -Method 'GET' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test query parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER QueryObject +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-QueryStyleDeepObjectExplodeTrueObject { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [PSCustomObject] + ${QueryObject}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-QueryStyleDeepObjectExplodeTrueObject' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + $LocalVarUri = '/query/style_deepObject/explode_true/object' + + if ($QueryObject) { + $LocalVarQueryParameters['query_object'] = $QueryObject + } + + $LocalVarResult = Invoke-ApiClient -Method 'GET' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test query parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER QueryObject +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-QueryStyleDeepObjectExplodeTrueObjectAllOf { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [PSCustomObject] + ${QueryObject}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-QueryStyleDeepObjectExplodeTrueObjectAllOf' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + $LocalVarUri = '/query/style_deepObject/explode_true/object/allOf' + + if ($QueryObject) { + $LocalVarQueryParameters['query_object'] = $QueryObject + } + + $LocalVarResult = Invoke-ApiClient -Method 'GET' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test query parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER QueryObject +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-QueryStyleFormExplodeTrueArrayString { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [PSCustomObject] + ${QueryObject}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-QueryStyleFormExplodeTrueArrayString' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + $LocalVarUri = '/query/style_form/explode_true/array_string' + + if ($QueryObject) { + $LocalVarQueryParameters['query_object'] = $QueryObject + } + + $LocalVarResult = Invoke-ApiClient -Method 'GET' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test query parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER QueryObject +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-QueryStyleFormExplodeTrueObject { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [PSCustomObject] + ${QueryObject}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-QueryStyleFormExplodeTrueObject' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + $LocalVarUri = '/query/style_form/explode_true/object' + + if ($QueryObject) { + $LocalVarQueryParameters['query_object'] = $QueryObject + } + + $LocalVarResult = Invoke-ApiClient -Method 'GET' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + +<# +.SYNOPSIS + +Test query parameter(s) + +.DESCRIPTION + +No description available. + +.PARAMETER QueryObject +No description available. + +.PARAMETER WithHttpInfo + +A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response + +.OUTPUTS + +String +#> +function Test-QueryStyleFormExplodeTrueObjectAllOf { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)] + [PSCustomObject] + ${QueryObject}, + [Switch] + $WithHttpInfo + ) + + Process { + 'Calling method: Test-QueryStyleFormExplodeTrueObjectAllOf' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $LocalVarAccepts = @() + $LocalVarContentTypes = @() + $LocalVarQueryParameters = @{} + $LocalVarHeaderParameters = @{} + $LocalVarFormParameters = @{} + $LocalVarPathParameters = @{} + $LocalVarCookieParameters = @{} + $LocalVarBodyParameter = $null + + $Configuration = Get-Configuration + # HTTP header 'Accept' (if needed) + $LocalVarAccepts = @('text/plain') + + $LocalVarUri = '/query/style_form/explode_true/object/allOf' + + if ($QueryObject) { + $LocalVarQueryParameters['query_object'] = $QueryObject + } + + $LocalVarResult = Invoke-ApiClient -Method 'GET' ` + -Uri $LocalVarUri ` + -Accepts $LocalVarAccepts ` + -ContentTypes $LocalVarContentTypes ` + -Body $LocalVarBodyParameter ` + -HeaderParameters $LocalVarHeaderParameters ` + -QueryParameters $LocalVarQueryParameters ` + -FormParameters $LocalVarFormParameters ` + -CookieParameters $LocalVarCookieParameters ` + -ReturnType "String" ` + -IsBodyNullable $false + + if ($WithHttpInfo.IsPresent) { + return $LocalVarResult + } else { + return $LocalVarResult["Response"] + } + } +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Client/Configuration.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Client/Configuration.ps1 new file mode 100644 index 000000000000..9e1aa107bbc1 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Client/Configuration.ps1 @@ -0,0 +1,515 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +Get the configuration object 'Configuration'. + +.DESCRIPTION + +Get the configuration object 'Configuration'. + +.OUTPUTS + +System.Collections.Hashtable +#> +function Get-Configuration { + + $Configuration = $Script:Configuration + + if ([string]::IsNullOrEmpty($Configuration["BaseUrl"])) { + $Configuration["BaseUrl"] = "http://localhost:3000"; + } + + if (!$Configuration.containsKey("Username")) { + $Configuration["Username"] = $null + } + if (!$Configuration.containsKey("Password")) { + $Configuration["Password"] = $null + } + if (!$Configuration.containsKey("AccessToken")) { + $Configuration["AccessToken"] = $null + } + if (!$Configuration.containsKey("Cookie")) { + $Configuration["Cookie"] = $null + } + + if (!$Configuration["DefaultHeaders"]) { + $Configuration["DefaultHeaders"] = @{} + } + + if (!$Configuration["ApiKey"]) { + $Configuration["ApiKey"] = @{} + } + + if (!$Configuration["ApiKeyPrefix"]) { + $Configuration["ApiKeyPrefix"] = @{} + } + + if (!$Configuration.containsKey("SkipCertificateCheck")) { + $Configuration["SkipCertificateCheck"] = $false + } + + if (!$Configuration.containsKey("Proxy")) { + $Configuration["Proxy"] = $null + } + + Return $Configuration + +} + +<# +.SYNOPSIS + +Set the configuration. + +.DESCRIPTION + +Set the configuration. + +.PARAMETER BaseUrl +Base URL of the HTTP endpoints + +.PARAMETER Username +Username in HTTP basic authentication + +.PARAMETER Password +Password in HTTP basic authentication + +.PARAMETER ApiKey +API Keys for authentication/authorization + +.PARAMETER ApiKeyPrefix +Prefix in the API Keys + +.PARAMETER Cookie +Cookie for authentication/authorization + +.PARAMETER AccessToken +Access token for authentication/authorization + +.PARAMETER SkipCertificateCheck +Skip certificate verification + +.PARAMETER DefaultHeaders +Default HTTP headers to be included in the HTTP request + +.PARAMETER Proxy +Proxy setting in the HTTP request, e.g. + +$proxy = [System.Net.WebRequest]::GetSystemWebProxy() +$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials + +.PARAMETER PassThru +Return an object of the Configuration + +.OUTPUTS + +System.Collections.Hashtable +#> +function Set-Configuration { + + [CmdletBinding()] + Param( + [string]$BaseUrl, + [AllowEmptyString()] + [string]$Username, + [AllowEmptyString()] + [string]$Password, + [hashtable]$ApiKey, + [hashtable]$ApiKeyPrefix, + [AllowEmptyString()] + [string]$Cookie, + [AllowEmptyString()] + [string]$AccessToken, + [switch]$SkipCertificateCheck, + [hashtable]$DefaultHeaders, + [System.Object]$Proxy, + [switch]$PassThru + ) + + Process { + + If ($BaseUrl) { + # validate URL + $URL = $BaseUrl -as [System.URI] + if (!($null -ne $URL.AbsoluteURI -and $URL.Scheme -match '[http|https]')) { + throw "Invalid URL '$($BaseUrl)' cannot be used in the base URL." + } + $Script:Configuration["BaseUrl"] = $BaseUrl + } + + If ($Username) { + $Script:Configuration['Username'] = $Username + } + + If ($Password) { + $Script:Configuration['Password'] = $Password + } + + If ($ApiKey) { + $Script:Configuration['ApiKey'] = $ApiKey + } + + If ($ApiKeyPrefix) { + $Script:Configuration['ApiKeyPrefix'] = $ApiKeyPrefix + } + + If ($Cookie) { + $Script:Configuration['Cookie'] = $Cookie + } + + If ($AccessToken) { + $Script:Configuration['AccessToken'] = $AccessToken + } + + If ($SkipCertificateCheck.IsPresent) { + $Script:Configuration['SkipCertificateCheck'] = $true + } else { + $Script:Configuration['SkipCertificateCheck'] = $false + } + + If ($DefaultHeaders) { + $Script:Configuration['DefaultHeaders'] = $DefaultHeaders + } + + If ($null -ne $Proxy) { + If ($Proxy.GetType().FullName -ne "System.Net.SystemWebProxy" -and $Proxy.GetType().FullName -ne "System.Net.WebRequest+WebProxyWrapperOpaque") { + throw "Incorrect Proxy type '$($Proxy.GetType().FullName)'. Must be System.Net.SystemWebProxy or System.Net.WebRequest+WebProxyWrapperOpaque." + } + $Script:Configuration['Proxy'] = $Proxy + } else { + $Script:Configuration['Proxy'] = $null + } + + If ($PassThru.IsPresent) { + $Script:Configuration + } + } +} + +<# +.SYNOPSIS + +Set the API Key. + +.DESCRIPTION + +Set the API Key. + +.PARAMETER Id +ID of the security schema + +.PARAMETER ApiKey +API Key + +.OUTPUTS + +None +#> +function Set-ConfigurationApiKey { + [CmdletBinding()] + Param( + [string]$Id, + [AllowEmptyString()] + [string]$ApiKey + ) + Process { + if (!$Script:Configuration["ApiKey"]) { + $Script:Configuration["ApiKey"] = @{} + } + $Script:Configuration["ApiKey"][$Id] = $ApiKey + } +} + +<# +.SYNOPSIS + +Set the API Key prefix. + +.DESCRIPTION + +Set the API Key prefix. + +.PARAMETER Id +ID of the security schema + +.PARAMETER ApiKey +API Key prefix + +.OUTPUTS + +None +#> +function Set-ConfigurationApiKeyPrefix { + [CmdletBinding()] + Param( + [string]$Id, + [AllowEmptyString()] + [string]$ApiKeyPrefix + ) + Process { + if (!$Script:Configuration["ApiKeyPrefix"]) { + $Script:Configuration["ApiKeyPrefix"] = @{} + } + $Script:Configuration["ApiKeyPrefix"][$Id] = $ApiKeyPrefix + } +} + +<# +.SYNOPSIS + +Set the default header. + +.DESCRIPTION + +Set the default header. + +.PARAMETER Key +Key of the HTTP header + +.PARAMETER Value +Value of the HTTP header + +.OUTPUTS + +None +#> +function Set-ConfigurationDefaultHeader { + [CmdletBinding()] + Param( + [string]$Key, + [AllowEmptyString()] + [string]$Value + ) + Process { + if (!$Script:Configuration["DefaultHeaders"]) { + $Script:Configuration["DefaultHeaders"] = @{} + } + $Script:Configuration["DefaultHeaders"][$Key] = $Value + } +} + + +<# +.SYNOPSIS + +Get the host setting. + +.DESCRIPTION + +Get the host setting in the form of array of hashtables. + +.OUTPUTS + +System.Collections.Hashtable[] +#> +function Get-HostSetting { + return ,@( + @{ + "Url" = "http://localhost:3000"; + "Description" = "No description provided"; + } + ) + +} + +<# +.SYNOPSIS + +Get the URL from the host settings. + +.PARAMETER Index +Index of the host settings (array) + +.PARAMETER Variables +Names and values of the variables (hashtable) + +.DESCRIPTION + +Get the URL from the host settings. + +.OUTPUTS + +String +#> +function Get-UrlFromHostSetting { + + [CmdletBinding()] + Param( + [Parameter(ValueFromPipeline = $true)] + [Int]$Index, + [Hashtable]$Variables = @{} + ) + + Process { + $Hosts = Get-HostSetting + + # check array index out of bound + if ($Index -lt 0 -or $Index -ge $Hosts.Length) { + throw "Invalid index $index when selecting the host. Must be less than $($Hosts.Length)" + } + + $MyHost = $Hosts[$Index]; + $Url = $MyHost["Url"]; + + # go through variable and assign a value + foreach ($h in $MyHost["Variables"].GetEnumerator()) { + if ($Variables.containsKey($h.Name)) { # check to see if it's in the variables provided by the user + if ($h.Value["EnumValues"] -Contains $Variables[$h.Name]) { + $Url = $Url.replace("{$($h.Name)}", $Variables[$h.Name]) + } else { + throw "The variable '$($h.Name)' in the host URL has invalid value $($Variables[$h.Name]). Must be $($h.Value["EnumValues"] -join ",")" + } + } else { + $Url = $Url.replace("{$($h.Name)}", $h.Value["DefaultValue"]) + } + } + + return $Url; + + } +} + +<# +.SYNOPSIS +Sets the configuration for http signing. +.DESCRIPTION + +Sets the configuration for the HTTP signature security scheme. +The HTTP signature security scheme is used to sign HTTP requests with a key +which is in possession of the API client. +An 'Authorization' header is calculated by creating a hash of select headers, +and optionally the body of the HTTP request, then signing the hash value using +a key. The 'Authorization' header is added to outbound HTTP requests. + +Ref: https://openapi-generator.tech + +.PARAMETER KeyId +KeyId for HTTP signing + +.PARAMETER KeyFilePath +KeyFilePath for HTTP signing + +.PARAMETER KeyPassPhrase +KeyPassPhrase, if the HTTP signing key is protected + +.PARAMETER HttpSigningHeader +HttpSigningHeader list of HTTP headers used to calculate the signature. The two special signature headers '(request-target)' and '(created)' +SHOULD be included. + The '(created)' header expresses when the signature was created. + The '(request-target)' header is a concatenation of the lowercased :method, an + ASCII space, and the :path pseudo-headers. +If no headers are specified then '(created)' sets as default. + +.PARAMETER HashAlgorithm +HashAlgorithm to calculate the hash, Supported values are "sha256" and "sha512" + +.PARAMETER SigningAlgorithm +SigningAlgorithm specifies the signature algorithm, supported values are "RSASSA-PKCS1-v1_5" and "RSASSA-PSS" +RSA key : Supported values "RSASSA-PKCS1-v1_5" and "RSASSA-PSS", for ECDSA key this parameter is not applicable + +.PARAMETER SignatureValidityPeriod +SignatureValidityPeriod specifies the signature maximum validity time in seconds. It accepts integer value + +.OUTPUTS + +System.Collections.Hashtable +#> +function Set-ConfigurationHttpSigning { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string]$KeyId, + [Parameter(Mandatory = $true)] + [string]$KeyFilePath, + [Parameter(Mandatory = $false)] + [securestring]$KeyPassPhrase, + [Parameter(Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [string[]] $HttpSigningHeader = @("(created)"), + [Parameter(Mandatory = $false)] + [ValidateSet("sha256", "sha512")] + [string] $HashAlgorithm = "sha256", + [Parameter(Mandatory = $false)] + [ValidateSet("RSASSA-PKCS1-v1_5", "RSASSA-PSS")] + [string]$SigningAlgorithm , + [Parameter(Mandatory = $false)] + [int]$SignatureValidityPeriod + ) + + Process { + $httpSignatureConfiguration = @{ } + + if (Test-Path -Path $KeyFilePath) { + $httpSignatureConfiguration["KeyId"] = $KeyId + $httpSignatureConfiguration["KeyFilePath"] = $KeyFilePath + } + else { + throw "Private key file path does not exist" + } + + $keyType = Get-KeyTypeFromFile -KeyFilePath $KeyFilePath + if ([String]::IsNullOrEmpty($SigningAlgorithm)) { + if ($keyType -eq "RSA") { + $SigningAlgorithm = "RSASSA-PKCS1-v1_5" + } + } + + if ($keyType -eq "RSA" -and + ($SigningAlgorithm -ne "RSASSA-PKCS1-v1_5" -and $SigningAlgorithm -ne "RSASSA-PSS" )) { + throw "Provided Key and SigningAlgorithm : $SigningAlgorithm is not compatible." + } + + if ($HttpSigningHeader -contains "(expires)" -and $SignatureValidityPeriod -le 0) { + throw "SignatureValidityPeriod must be greater than 0 seconds." + } + + if ($HttpSigningHeader -contains "(expires)") { + $httpSignatureConfiguration["SignatureValidityPeriod"] = $SignatureValidityPeriod + } + if ($null -ne $HttpSigningHeader -and $HttpSigningHeader.Length -gt 0) { + $httpSignatureConfiguration["HttpSigningHeader"] = $HttpSigningHeader + } + + if ($null -ne $HashAlgorithm ) { + $httpSignatureConfiguration["HashAlgorithm"] = $HashAlgorithm + } + + if ($null -ne $SigningAlgorithm) { + $httpSignatureConfiguration["SigningAlgorithm"] = $SigningAlgorithm + } + + if ($null -ne $KeyPassPhrase) { + $httpSignatureConfiguration["KeyPassPhrase"] = $KeyPassPhrase + } + + $Script:Configuration["HttpSigning"] = New-Object -TypeName PSCustomObject -Property $httpSignatureConfiguration + } +} + +<# +.SYNOPSIS + +Get the configuration object 'ConfigurationHttpSigning'. + +.DESCRIPTION + +Get the configuration object 'ConfigurationHttpSigning'. + +.OUTPUTS + +[PSCustomObject] +#> +function Get-ConfigurationHttpSigning{ + + $httpSignatureConfiguration = $Script:Configuration["HttpSigning"] + return $httpSignatureConfiguration +} diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Bird.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Bird.ps1 new file mode 100644 index 000000000000..e699ce79035f --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Bird.ps1 @@ -0,0 +1,111 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +No description available. + +.PARAMETER Size +No description available. +.PARAMETER Color +No description available. +.OUTPUTS + +Bird +#> + +function Initialize-Bird { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [String] + ${Size}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)] + [String] + ${Color} + ) + + Process { + 'Creating PSCustomObject: PSOpenAPITools => Bird' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + + $PSO = [PSCustomObject]@{ + "size" = ${Size} + "color" = ${Color} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to Bird + +.DESCRIPTION + +Convert from JSON to Bird + +.PARAMETER Json + +Json object + +.OUTPUTS + +Bird +#> +function ConvertFrom-JsonToBird { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSOpenAPITools => Bird' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in Bird + $AllProperties = ("size", "color") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "size"))) { #optional property not found + $Size = $null + } else { + $Size = $JsonParameters.PSobject.Properties["size"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "color"))) { #optional property not found + $Color = $null + } else { + $Color = $JsonParameters.PSobject.Properties["color"].value + } + + $PSO = [PSCustomObject]@{ + "size" = ${Size} + "color" = ${Color} + } + + return $PSO + } + +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Category.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Category.ps1 new file mode 100644 index 000000000000..4e561693da9a --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Category.ps1 @@ -0,0 +1,111 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +No description available. + +.PARAMETER Id +No description available. +.PARAMETER Name +No description available. +.OUTPUTS + +Category +#> + +function Initialize-Category { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [System.Nullable[Int64]] + ${Id}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)] + [String] + ${Name} + ) + + Process { + 'Creating PSCustomObject: PSOpenAPITools => Category' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + + $PSO = [PSCustomObject]@{ + "id" = ${Id} + "name" = ${Name} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to Category + +.DESCRIPTION + +Convert from JSON to Category + +.PARAMETER Json + +Json object + +.OUTPUTS + +Category +#> +function ConvertFrom-JsonToCategory { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSOpenAPITools => Category' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in Category + $AllProperties = ("id", "name") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "id"))) { #optional property not found + $Id = $null + } else { + $Id = $JsonParameters.PSobject.Properties["id"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "name"))) { #optional property not found + $Name = $null + } else { + $Name = $JsonParameters.PSobject.Properties["name"].value + } + + $PSO = [PSCustomObject]@{ + "id" = ${Id} + "name" = ${Name} + } + + return $PSO + } + +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/DataQuery.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/DataQuery.ps1 new file mode 100644 index 000000000000..9fadb40d2278 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/DataQuery.ps1 @@ -0,0 +1,151 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +No description available. + +.PARAMETER Id +Query +.PARAMETER Outcomes +No description available. +.PARAMETER Suffix +test suffix +.PARAMETER Text +Some text containing white spaces +.PARAMETER Date +A date +.OUTPUTS + +DataQuery +#> + +function Initialize-DataQuery { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [System.Nullable[Int64]] + ${Id}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)] + [ValidateSet("SUCCESS", "FAILURE", "SKIPPED")] + [String[]] + ${Outcomes}, + [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)] + [String] + ${Suffix}, + [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)] + [String] + ${Text}, + [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)] + [System.Nullable[System.DateTime]] + ${Date} + ) + + Process { + 'Creating PSCustomObject: PSOpenAPITools => DataQuery' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + + $PSO = [PSCustomObject]@{ + "id" = ${Id} + "outcomes" = ${Outcomes} + "suffix" = ${Suffix} + "text" = ${Text} + "date" = ${Date} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to DataQuery + +.DESCRIPTION + +Convert from JSON to DataQuery + +.PARAMETER Json + +Json object + +.OUTPUTS + +DataQuery +#> +function ConvertFrom-JsonToDataQuery { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSOpenAPITools => DataQuery' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in DataQuery + $AllProperties = ("id", "outcomes", "suffix", "text", "date") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "id"))) { #optional property not found + $Id = $null + } else { + $Id = $JsonParameters.PSobject.Properties["id"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "outcomes"))) { #optional property not found + $Outcomes = $null + } else { + $Outcomes = $JsonParameters.PSobject.Properties["outcomes"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "suffix"))) { #optional property not found + $Suffix = $null + } else { + $Suffix = $JsonParameters.PSobject.Properties["suffix"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "text"))) { #optional property not found + $Text = $null + } else { + $Text = $JsonParameters.PSobject.Properties["text"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "date"))) { #optional property not found + $Date = $null + } else { + $Date = $JsonParameters.PSobject.Properties["date"].value + } + + $PSO = [PSCustomObject]@{ + "id" = ${Id} + "outcomes" = ${Outcomes} + "suffix" = ${Suffix} + "text" = ${Text} + "date" = ${Date} + } + + return $PSO + } + +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/DefaultValue.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/DefaultValue.ps1 new file mode 100644 index 000000000000..0b01f22b39b4 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/DefaultValue.ps1 @@ -0,0 +1,190 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +to test the default value of properties + +.PARAMETER ArrayStringEnumRefDefault +No description available. +.PARAMETER ArrayStringEnumDefault +No description available. +.PARAMETER ArrayStringDefault +No description available. +.PARAMETER ArrayIntegerDefault +No description available. +.PARAMETER ArrayString +No description available. +.PARAMETER ArrayStringNullable +No description available. +.PARAMETER ArrayStringExtensionNullable +No description available. +.PARAMETER StringNullable +No description available. +.OUTPUTS + +DefaultValue +#> + +function Initialize-DefaultValue { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [PSCustomObject[]] + ${ArrayStringEnumRefDefault}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)] + [ValidateSet("success", "failure", "unclassified")] + [String[]] + ${ArrayStringEnumDefault}, + [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)] + [String[]] + ${ArrayStringDefault}, + [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)] + [Int32[]] + ${ArrayIntegerDefault}, + [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)] + [String[]] + ${ArrayString}, + [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)] + [String[]] + ${ArrayStringNullable}, + [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)] + [String[]] + ${ArrayStringExtensionNullable}, + [Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)] + [String] + ${StringNullable} + ) + + Process { + 'Creating PSCustomObject: PSOpenAPITools => DefaultValue' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + + $PSO = [PSCustomObject]@{ + "array_string_enum_ref_default" = ${ArrayStringEnumRefDefault} + "array_string_enum_default" = ${ArrayStringEnumDefault} + "array_string_default" = ${ArrayStringDefault} + "array_integer_default" = ${ArrayIntegerDefault} + "array_string" = ${ArrayString} + "array_string_nullable" = ${ArrayStringNullable} + "array_string_extension_nullable" = ${ArrayStringExtensionNullable} + "string_nullable" = ${StringNullable} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to DefaultValue + +.DESCRIPTION + +Convert from JSON to DefaultValue + +.PARAMETER Json + +Json object + +.OUTPUTS + +DefaultValue +#> +function ConvertFrom-JsonToDefaultValue { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSOpenAPITools => DefaultValue' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in DefaultValue + $AllProperties = ("array_string_enum_ref_default", "array_string_enum_default", "array_string_default", "array_integer_default", "array_string", "array_string_nullable", "array_string_extension_nullable", "string_nullable") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_string_enum_ref_default"))) { #optional property not found + $ArrayStringEnumRefDefault = $null + } else { + $ArrayStringEnumRefDefault = $JsonParameters.PSobject.Properties["array_string_enum_ref_default"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_string_enum_default"))) { #optional property not found + $ArrayStringEnumDefault = $null + } else { + $ArrayStringEnumDefault = $JsonParameters.PSobject.Properties["array_string_enum_default"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_string_default"))) { #optional property not found + $ArrayStringDefault = $null + } else { + $ArrayStringDefault = $JsonParameters.PSobject.Properties["array_string_default"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_integer_default"))) { #optional property not found + $ArrayIntegerDefault = $null + } else { + $ArrayIntegerDefault = $JsonParameters.PSobject.Properties["array_integer_default"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_string"))) { #optional property not found + $ArrayString = $null + } else { + $ArrayString = $JsonParameters.PSobject.Properties["array_string"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_string_nullable"))) { #optional property not found + $ArrayStringNullable = $null + } else { + $ArrayStringNullable = $JsonParameters.PSobject.Properties["array_string_nullable"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "array_string_extension_nullable"))) { #optional property not found + $ArrayStringExtensionNullable = $null + } else { + $ArrayStringExtensionNullable = $JsonParameters.PSobject.Properties["array_string_extension_nullable"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "string_nullable"))) { #optional property not found + $StringNullable = $null + } else { + $StringNullable = $JsonParameters.PSobject.Properties["string_nullable"].value + } + + $PSO = [PSCustomObject]@{ + "array_string_enum_ref_default" = ${ArrayStringEnumRefDefault} + "array_string_enum_default" = ${ArrayStringEnumDefault} + "array_string_default" = ${ArrayStringDefault} + "array_integer_default" = ${ArrayIntegerDefault} + "array_string" = ${ArrayString} + "array_string_nullable" = ${ArrayStringNullable} + "array_string_extension_nullable" = ${ArrayStringExtensionNullable} + "string_nullable" = ${StringNullable} + } + + return $PSO + } + +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/NumberPropertiesOnly.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/NumberPropertiesOnly.ps1 new file mode 100644 index 000000000000..131819de86a5 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/NumberPropertiesOnly.ps1 @@ -0,0 +1,132 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +No description available. + +.PARAMETER Number +No description available. +.PARAMETER Float +No description available. +.PARAMETER Double +No description available. +.OUTPUTS + +NumberPropertiesOnly +#> + +function Initialize-NumberPropertiesOnly { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [System.Nullable[Decimal]] + ${Number}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)] + [System.Nullable[Double]] + ${Float}, + [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)] + [System.Nullable[Double]] + ${Double} + ) + + Process { + 'Creating PSCustomObject: PSOpenAPITools => NumberPropertiesOnly' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + if ($Double -and $Double -gt 50.2) { + throw "invalid value for 'Double', must be smaller than or equal to 50.2." + } + + if ($Double -and $Double -lt 0.8) { + throw "invalid value for 'Double', must be greater than or equal to 0.8." + } + + + $PSO = [PSCustomObject]@{ + "number" = ${Number} + "float" = ${Float} + "double" = ${Double} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to NumberPropertiesOnly + +.DESCRIPTION + +Convert from JSON to NumberPropertiesOnly + +.PARAMETER Json + +Json object + +.OUTPUTS + +NumberPropertiesOnly +#> +function ConvertFrom-JsonToNumberPropertiesOnly { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSOpenAPITools => NumberPropertiesOnly' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in NumberPropertiesOnly + $AllProperties = ("number", "float", "double") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "number"))) { #optional property not found + $Number = $null + } else { + $Number = $JsonParameters.PSobject.Properties["number"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "float"))) { #optional property not found + $Float = $null + } else { + $Float = $JsonParameters.PSobject.Properties["float"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "double"))) { #optional property not found + $Double = $null + } else { + $Double = $JsonParameters.PSobject.Properties["double"].value + } + + $PSO = [PSCustomObject]@{ + "number" = ${Number} + "float" = ${Float} + "double" = ${Double} + } + + return $PSO + } + +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Pet.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Pet.ps1 new file mode 100644 index 000000000000..e89786caafd9 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Pet.ps1 @@ -0,0 +1,176 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +No description available. + +.PARAMETER Id +No description available. +.PARAMETER Name +No description available. +.PARAMETER Category +No description available. +.PARAMETER PhotoUrls +No description available. +.PARAMETER Tags +No description available. +.PARAMETER Status +pet status in the store +.OUTPUTS + +Pet +#> + +function Initialize-Pet { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [System.Nullable[Int64]] + ${Id}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)] + [String] + ${Name}, + [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)] + [PSCustomObject] + ${Category}, + [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)] + [String[]] + ${PhotoUrls}, + [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)] + [PSCustomObject[]] + ${Tags}, + [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)] + [ValidateSet("available", "pending", "sold")] + [String] + ${Status} + ) + + Process { + 'Creating PSCustomObject: PSOpenAPITools => Pet' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + if ($null -eq $Name) { + throw "invalid value for 'Name', 'Name' cannot be null." + } + + if ($null -eq $PhotoUrls) { + throw "invalid value for 'PhotoUrls', 'PhotoUrls' cannot be null." + } + + + $PSO = [PSCustomObject]@{ + "id" = ${Id} + "name" = ${Name} + "category" = ${Category} + "photoUrls" = ${PhotoUrls} + "tags" = ${Tags} + "status" = ${Status} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to Pet + +.DESCRIPTION + +Convert from JSON to Pet + +.PARAMETER Json + +Json object + +.OUTPUTS + +Pet +#> +function ConvertFrom-JsonToPet { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSOpenAPITools => Pet' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in Pet + $AllProperties = ("id", "name", "category", "photoUrls", "tags", "status") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + If ([string]::IsNullOrEmpty($Json) -or $Json -eq "{}") { # empty json + throw "Error! Empty JSON cannot be serialized due to the required property 'name' missing." + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "name"))) { + throw "Error! JSON cannot be serialized due to the required property 'name' missing." + } else { + $Name = $JsonParameters.PSobject.Properties["name"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "photoUrls"))) { + throw "Error! JSON cannot be serialized due to the required property 'photoUrls' missing." + } else { + $PhotoUrls = $JsonParameters.PSobject.Properties["photoUrls"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "id"))) { #optional property not found + $Id = $null + } else { + $Id = $JsonParameters.PSobject.Properties["id"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "category"))) { #optional property not found + $Category = $null + } else { + $Category = $JsonParameters.PSobject.Properties["category"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "tags"))) { #optional property not found + $Tags = $null + } else { + $Tags = $JsonParameters.PSobject.Properties["tags"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "status"))) { #optional property not found + $Status = $null + } else { + $Status = $JsonParameters.PSobject.Properties["status"].value + } + + $PSO = [PSCustomObject]@{ + "id" = ${Id} + "name" = ${Name} + "category" = ${Category} + "photoUrls" = ${PhotoUrls} + "tags" = ${Tags} + "status" = ${Status} + } + + return $PSO + } + +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Query.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Query.ps1 new file mode 100644 index 000000000000..def037062dc7 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Query.ps1 @@ -0,0 +1,112 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +No description available. + +.PARAMETER Id +Query +.PARAMETER Outcomes +No description available. +.OUTPUTS + +Query +#> + +function Initialize-Query { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [System.Nullable[Int64]] + ${Id}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)] + [ValidateSet("SUCCESS", "FAILURE", "SKIPPED")] + [String[]] + ${Outcomes} + ) + + Process { + 'Creating PSCustomObject: PSOpenAPITools => Query' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + + $PSO = [PSCustomObject]@{ + "id" = ${Id} + "outcomes" = ${Outcomes} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to Query + +.DESCRIPTION + +Convert from JSON to Query + +.PARAMETER Json + +Json object + +.OUTPUTS + +Query +#> +function ConvertFrom-JsonToQuery { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSOpenAPITools => Query' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in Query + $AllProperties = ("id", "outcomes") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "id"))) { #optional property not found + $Id = $null + } else { + $Id = $JsonParameters.PSobject.Properties["id"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "outcomes"))) { #optional property not found + $Outcomes = $null + } else { + $Outcomes = $JsonParameters.PSobject.Properties["outcomes"].value + } + + $PSO = [PSCustomObject]@{ + "id" = ${Id} + "outcomes" = ${Outcomes} + } + + return $PSO + } + +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/StringEnumRef.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/StringEnumRef.ps1 new file mode 100644 index 000000000000..3ea65a59c5ac --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/StringEnumRef.ps1 @@ -0,0 +1,27 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +Enum StringEnumRef. + +.DESCRIPTION + +No description available. +#> + +enum StringEnumRef { + # enum value: "success" + success + # enum value: "failure" + failure + # enum value: "unclassified" + unclassified +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Tag.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Tag.ps1 new file mode 100644 index 000000000000..ab572c56d99f --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/Tag.ps1 @@ -0,0 +1,111 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +No description available. + +.PARAMETER Id +No description available. +.PARAMETER Name +No description available. +.OUTPUTS + +Tag +#> + +function Initialize-Tag { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [System.Nullable[Int64]] + ${Id}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)] + [String] + ${Name} + ) + + Process { + 'Creating PSCustomObject: PSOpenAPITools => Tag' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + + $PSO = [PSCustomObject]@{ + "id" = ${Id} + "name" = ${Name} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to Tag + +.DESCRIPTION + +Convert from JSON to Tag + +.PARAMETER Json + +Json object + +.OUTPUTS + +Tag +#> +function ConvertFrom-JsonToTag { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSOpenAPITools => Tag' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in Tag + $AllProperties = ("id", "name") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "id"))) { #optional property not found + $Id = $null + } else { + $Id = $JsonParameters.PSobject.Properties["id"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "name"))) { #optional property not found + $Name = $null + } else { + $Name = $JsonParameters.PSobject.Properties["name"].value + } + + $PSO = [PSCustomObject]@{ + "id" = ${Id} + "name" = ${Name} + } + + return $PSO + } + +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.ps1 new file mode 100644 index 000000000000..e38d86a22b86 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.ps1 @@ -0,0 +1,137 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +No description available. + +.PARAMETER Size +No description available. +.PARAMETER Color +No description available. +.PARAMETER Id +No description available. +.PARAMETER Name +No description available. +.OUTPUTS + +TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter +#> + +function Initialize-TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [String] + ${Size}, + [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)] + [String] + ${Color}, + [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)] + [System.Nullable[Int64]] + ${Id}, + [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)] + [String] + ${Name} + ) + + Process { + 'Creating PSCustomObject: PSOpenAPITools => TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + + $PSO = [PSCustomObject]@{ + "size" = ${Size} + "color" = ${Color} + "id" = ${Id} + "name" = ${Name} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + +.DESCRIPTION + +Convert from JSON to TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + +.PARAMETER Json + +Json object + +.OUTPUTS + +TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter +#> +function ConvertFrom-JsonToTestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSOpenAPITools => TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + $AllProperties = ("size", "color", "id", "name") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "size"))) { #optional property not found + $Size = $null + } else { + $Size = $JsonParameters.PSobject.Properties["size"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "color"))) { #optional property not found + $Color = $null + } else { + $Color = $JsonParameters.PSobject.Properties["color"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "id"))) { #optional property not found + $Id = $null + } else { + $Id = $JsonParameters.PSobject.Properties["id"].value + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "name"))) { #optional property not found + $Name = $null + } else { + $Name = $JsonParameters.PSobject.Properties["name"].value + } + + $PSO = [PSCustomObject]@{ + "size" = ${Size} + "color" = ${Color} + "id" = ${Id} + "name" = ${Name} + } + + return $PSO + } + +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.ps1 new file mode 100644 index 000000000000..61b7084242be --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.ps1 @@ -0,0 +1,98 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +No description available. + +.PARAMETER Values +No description available. +.OUTPUTS + +TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter +#> + +function Initialize-TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [String[]] + ${Values} + ) + + Process { + 'Creating PSCustomObject: PSOpenAPITools => TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + + $PSO = [PSCustomObject]@{ + "values" = ${Values} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + +.DESCRIPTION + +Convert from JSON to TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + +.PARAMETER Json + +Json object + +.OUTPUTS + +TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter +#> +function ConvertFrom-JsonToTestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSOpenAPITools => TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + $AllProperties = ("values") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "values"))) { #optional property not found + $Values = $null + } else { + $Values = $JsonParameters.PSobject.Properties["values"].value + } + + $PSO = [PSCustomObject]@{ + "values" = ${Values} + } + + return $PSO + } + +} + diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/PSOpenAPITools.psm1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/PSOpenAPITools.psm1 new file mode 100644 index 000000000000..daf04503ba97 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/PSOpenAPITools.psm1 @@ -0,0 +1,38 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +#region Import functions + +# define the following classes in PowerShell +try { + Add-Type -AssemblyName System.Web -ErrorAction Ignore | Out-Null + Add-Type -AssemblyName System.Net -ErrorAction Ignore | Out-Null +} catch { + Write-Verbose $_ +} + +# set $ErrorActionPreference to 'Stop' globally +$ErrorActionPreference = 'Stop' + +# store the API client's configuration +$Script:Configuration = [System.Collections.HashTable]@{} + +$Script:CmdletBindingParameters = @('Verbose','Debug','ErrorAction','WarningAction','InformationAction','ErrorVariable','WarningVariable','InformationVariable','OutVariable','OutBuffer','PipelineVariable') + +'Api', 'Model', 'Client', 'Private' | Get-ChildItem -Path { + Join-Path $PSScriptRoot $_ +} -Filter '*.ps1' | ForEach-Object { + Write-Debug "Importing file: $($_.BaseName)" + try { + . $_.FullName + } catch { + Write-Error -Message "Failed to import function $($_.Fullname): $_" + } +} + +#endregion diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/ApiClient.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/ApiClient.ps1 new file mode 100644 index 000000000000..b25a9e4b0ee4 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/ApiClient.ps1 @@ -0,0 +1,260 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +function Invoke-ApiClient { + [OutputType('System.Collections.Hashtable')] + [CmdletBinding()] + Param( + [Parameter(Mandatory)] + [string]$Uri, + [Parameter(Mandatory)] + [AllowEmptyCollection()] + [string[]]$Accepts, + [Parameter(Mandatory)] + [AllowEmptyCollection()] + [string[]]$ContentTypes, + [Parameter(Mandatory)] + [hashtable]$HeaderParameters, + [Parameter(Mandatory)] + [hashtable]$FormParameters, + [Parameter(Mandatory)] + [hashtable]$QueryParameters, + [Parameter(Mandatory)] + [hashtable]$CookieParameters, + [Parameter(Mandatory)] + [AllowEmptyString()] + [string]$Body, + [Parameter(Mandatory)] + [string]$Method, + [Parameter(Mandatory)] + [AllowEmptyString()] + [string]$ReturnType, + [Parameter(Mandatory)] + [bool]$IsBodyNullable + ) + + 'Calling method: Invoke-ApiClient' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $Configuration = Get-Configuration + $RequestUri = $Configuration["BaseUrl"] + $Uri + $SkipCertificateCheck = $Configuration["SkipCertificateCheck"] + + # cookie parameters + foreach ($Parameter in $CookieParameters.GetEnumerator()) { + if ($Parameter.Name -eq "cookieAuth") { + $HeaderParameters["Cookie"] = $Parameter.Value + } else { + $HeaderParameters[$Parameter.Name] = $Parameter.Value + } + } + if ($CookieParameters -and $CookieParameters.Count -gt 1) { + Write-Warning "Multiple cookie parameters found. Currently only the first one is supported/used" + } + + # accept, content-type headers + $Accept = SelectHeaders -Headers $Accepts + if ($Accept) { + $HeaderParameters['Accept'] = $Accept + } + + [string]$MultiPartBoundary = $null + $ContentType= SelectHeaders -Headers $ContentTypes + if ($ContentType) { + $HeaderParameters['Content-Type'] = $ContentType + if ($ContentType -eq 'multipart/form-data') { + [string]$MultiPartBoundary = [System.Guid]::NewGuid() + $MultiPartBoundary = "---------------------------$MultiPartBoundary" + $HeaderParameters['Content-Type'] = "$ContentType; boundary=$MultiPartBoundary" + } + } + + # add default headers if any + foreach ($header in $Configuration["DefaultHeaders"].GetEnumerator()) { + $HeaderParameters[$header.Name] = $header.Value + } + + # construct URL query string + $HttpValues = [System.Web.HttpUtility]::ParseQueryString([String]::Empty) + foreach ($Parameter in $QueryParameters.GetEnumerator()) { + if ($Parameter.Value.Count -gt 1) { // array + foreach ($Value in $Parameter.Value) { + $HttpValues.Add($Parameter.Key + '[]', $Value) + } + } else { + $HttpValues.Add($Parameter.Key,$Parameter.Value) + } + } + # Build the request and load it with the query string. + $UriBuilder = [System.UriBuilder]($RequestUri) + $UriBuilder.Query = $HttpValues.ToString() + + # include form parameters in the request body + if ($FormParameters -and $FormParameters.Count -gt 0) { + if (![string]::IsNullOrEmpty($MultiPartBoundary)) { + $RequestBody = "" + $LF = "`r`n" + $FormParameters.Keys | ForEach-Object { + $value = $FormParameters[$_] + $isFile = $value.GetType().FullName -eq "System.IO.FileInfo" + + $RequestBody += "--$MultiPartBoundary$LF" + $RequestBody += "Content-Disposition: form-data; name=`"$_`"" + if ($isFile) { + $fileName = $value.Name + $RequestBody += "; filename=`"$fileName`"$LF" + $RequestBody += "Content-Type: application/octet-stream$LF$LF" + $RequestBody += Get-Content -Path $value.FullName + } else { + $RequestBody += "$LF$LF" + $RequestBody += ([string]$value) + } + $RequestBody += "$LF--$MultiPartBoundary" + } + $RequestBody += "--" + } else { + $RequestBody = $FormParameters + } + } + + + + if ($Body -or $IsBodyNullable) { + $RequestBody = $Body + if ([string]::IsNullOrEmpty($RequestBody) -and $IsBodyNullable -eq $true) { + $RequestBody = "null" + } + } + + if ($SkipCertificateCheck -eq $true) { + if ($null -eq $Configuration["Proxy"]) { + # skip certification check, no proxy + $Response = Invoke-WebRequest -Uri $UriBuilder.Uri ` + -Method $Method ` + -Headers $HeaderParameters ` + -Body $RequestBody ` + -ErrorAction Stop ` + -UseBasicParsing ` + -SkipCertificateCheck + } else { + # skip certification check, use proxy + $Response = Invoke-WebRequest -Uri $UriBuilder.Uri ` + -Method $Method ` + -Headers $HeaderParameters ` + -Body $RequestBody ` + -ErrorAction Stop ` + -UseBasicParsing ` + -SkipCertificateCheck ` + -Proxy $Configuration["Proxy"].GetProxy($UriBuilder.Uri) ` + -ProxyUseDefaultCredentials + } + } else { + if ($null -eq $Configuration["Proxy"]) { + # perform certification check, no proxy + $Response = Invoke-WebRequest -Uri $UriBuilder.Uri ` + -Method $Method ` + -Headers $HeaderParameters ` + -Body $RequestBody ` + -ErrorAction Stop ` + -UseBasicParsing + } else { + # perform certification check, use proxy + $Response = Invoke-WebRequest -Uri $UriBuilder.Uri ` + -Method $Method ` + -Headers $HeaderParameters ` + -Body $RequestBody ` + -ErrorAction Stop ` + -UseBasicParsing ` + -Proxy $Configuration["Proxy"].GetProxy($UriBuilder.Uri) ` + -ProxyUseDefaultCredentials + } + } + + return @{ + Response = DeserializeResponse -Response $Response -ReturnType $ReturnType -ContentTypes $Response.Headers["Content-Type"] + StatusCode = $Response.StatusCode + Headers = $Response.Headers + } +} + +# Select JSON MIME if present, otherwise choose the first one if available +function SelectHeaders { + Param( + [Parameter(Mandatory)] + [AllowEmptyCollection()] + [String[]]$Headers + ) + + foreach ($Header in $Headers) { + if (IsJsonMIME -MIME $Header) { + return $Header + } + } + + if (!($Headers) -or $Headers.Count -eq 0) { + return $null + } else { + return $Headers[0] # return the first one + } +} + +function IsJsonMIME { + Param( + [Parameter(Mandatory)] + [string]$MIME + ) + + if ($MIME -match "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$") { + return $true + } else { + return $false + } +} + +function DeserializeResponse { + Param( + [Parameter(Mandatory)] + [AllowEmptyString()] + [string]$ReturnType, + [Parameter(Mandatory)] + [AllowEmptyString()] + [string]$Response, + [Parameter(Mandatory)] + [AllowEmptyCollection()] + [string[]]$ContentTypes + ) + + If ($null -eq $ContentTypes) { + $ContentTypes = [string[]]@() + } + + If ([string]::IsNullOrEmpty($ReturnType) -and $ContentTypes.Count -eq 0) { # void response + return $Response + } Elseif ($ReturnType -match '\[\]$') { # array + return ConvertFrom-Json $Response + } Elseif (@("String", "Boolean", "System.DateTime") -contains $ReturnType) { # string, boolean ,datetime + return $Response + } Else { # others (e.g. model, file) + if ($ContentTypes) { + $ContentType = $null + if ($ContentTypes.Count -gt 1) { + $ContentType = SelectHeaders -Headers $ContentTypes + } else { + $ContentType = $ContentTypes[0] + } + + if (IsJsonMIME -MIME $ContentType) { # JSON + return ConvertFrom-Json $Response + } else { # XML, file, etc + return $Response + } + } else { # no content type in response header, returning raw response + return $Response + } + } +} diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/Get-CommonParameters.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/Get-CommonParameters.ps1 new file mode 100644 index 000000000000..4fb1d8172ecd --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/Get-CommonParameters.ps1 @@ -0,0 +1,22 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.Synopsis + Helper function to get common parameters (Verbose, Debug, etc.) +.Example + Get-CommonParameters +#> +function Get-CommonParameters { + function tmp { + [CmdletBinding()] + Param () + } + + (Get-Command -Name tmp -CommandType Function).Parameters.Keys +} diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/HttpSignatureAuth.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/HttpSignatureAuth.ps1 new file mode 100644 index 000000000000..c0d7175768c0 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/HttpSignatureAuth.ps1 @@ -0,0 +1,437 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + Gets the headers for HTTP signature. +.DESCRIPTION + Gets the headers for the http signature. +.PARAMETER Method + HTTP method +.PARAMETER UriBuilder + UriBuilder for url and query parameter +.PARAMETER Body + Request body +.OUTPUTS + Hashtable +#> +function Get-HttpSignedHeader { + param( + [string]$Method, + [System.UriBuilder]$UriBuilder, + [string]$Body, + [hashtable]$RequestHeader + ) + + $HEADER_REQUEST_TARGET = '(request-target)' + # The time when the HTTP signature was generated. + $HEADER_CREATED = '(created)' + # The time when the HTTP signature expires. The API server should reject HTTP requests + # that have expired. + $HEADER_EXPIRES = '(expires)' + # The 'Host' header. + $HEADER_HOST = 'Host' + # The 'Date' header. + $HEADER_DATE = 'Date' + # When the 'Digest' header is included in the HTTP signature, the client automatically + # computes the digest of the HTTP request body, per RFC 3230. + $HEADER_DIGEST = 'Digest' + # The 'Authorization' header is automatically generated by the client. It includes + # the list of signed headers and a base64-encoded signature. + $HEADER_AUTHORIZATION = 'Authorization' + + #Hash table to store singed headers + $HttpSignedRequestHeader = @{ } + $HttpSignatureHeader = @{ } + $TargetHost = $UriBuilder.Host + $httpSigningConfiguration = Get-ConfigurationHttpSigning + $Digest = $null + + #get the body digest + $bodyHash = Get-StringHash -String $Body -HashName $httpSigningConfiguration.HashAlgorithm + if ($httpSigningConfiguration.HashAlgorithm -eq "SHA256") { + $Digest = [String]::Format("SHA-256={0}", [Convert]::ToBase64String($bodyHash)) + } elseif ($httpSigningConfiguration.HashAlgorithm -eq "SHA512") { + $Digest = [String]::Format("SHA-512={0}", [Convert]::ToBase64String($bodyHash)) + } + + $dateTime = Get-Date + #get the date in UTC + $currentDate = $dateTime.ToUniversalTime().ToString("r") + + foreach ($headerItem in $httpSigningConfiguration.HttpSigningHeader) { + + if ($headerItem -eq $HEADER_REQUEST_TARGET) { + $requestTargetPath = [string]::Format("{0} {1}{2}", $Method.ToLower(), $UriBuilder.Path, $UriBuilder.Query) + $HttpSignatureHeader.Add($HEADER_REQUEST_TARGET, $requestTargetPath) + } elseif ($headerItem -eq $HEADER_CREATED) { + $created = Get-UnixTime -Date $dateTime -TotalTime TotalSeconds + $HttpSignatureHeader.Add($HEADER_CREATED, $created) + } elseif ($headerItem -eq $HEADER_EXPIRES) { + $expire = $dateTime.AddSeconds($httpSigningConfiguration.SignatureValidityPeriod) + $expireEpocTime = Get-UnixTime -Date $expire -TotalTime TotalSeconds + $HttpSignatureHeader.Add($HEADER_EXPIRES, $expireEpocTime) + } elseif ($headerItem -eq $HEADER_HOST) { + $HttpSignedRequestHeader[$HEADER_HOST] = $TargetHost + $HttpSignatureHeader.Add($HEADER_HOST.ToLower(), $TargetHost) + } elseif ($headerItem -eq $HEADER_DATE) { + $HttpSignedRequestHeader[$HEADER_DATE] = $currentDate + $HttpSignatureHeader.Add($HEADER_DATE.ToLower(), $currentDate) + } elseif ($headerItem -eq $HEADER_DIGEST) { + $HttpSignedRequestHeader[$HEADER_DIGEST] = $Digest + $HttpSignatureHeader.Add($HEADER_DIGEST.ToLower(), $Digest) + } elseif($RequestHeader.ContainsKey($headerItem)) { + $HttpSignatureHeader.Add($headerItem.ToLower(), $RequestHeader[$headerItem]) + } else { + throw "Cannot sign HTTP request. Request does not contain the $headerItem header." + } + } + + # header's name separated by space + $headersKeysString = $HttpSignatureHeader.Keys -join " " + $headerValuesList = @() + foreach ($item in $HttpSignatureHeader.GetEnumerator()) { + $headerValuesList += [string]::Format("{0}: {1}", $item.Name, $item.Value) + } + #Concatenate headers value separated by new line + $headerValuesString = $headerValuesList -join "`n" + + #Gets the hash of the headers value + $signatureHashString = Get-StringHash -String $headerValuesString -HashName $httpSigningConfiguration.HashAlgorithm + + #Gets the Key type to select the correct signing algorithm + $KeyType = Get-KeyTypeFromFile -KeyFilePath $httpSigningConfiguration.KeyFilePath + + if ($keyType -eq "RSA") { + $headerSignatureStr = Get-RSASignature -PrivateKeyFilePath $httpSigningConfiguration.KeyFilePath ` + -DataToSign $signatureHashString ` + -HashAlgorithmName $httpSigningConfiguration.HashAlgorithm ` + -KeyPassPhrase $httpSigningConfiguration.KeyPassPhrase ` + -SigningAlgorithm $httpSigningConfiguration.SigningAlgorithm + } elseif ($KeyType -eq "EC") { + $headerSignatureStr = Get-ECDSASignature -ECKeyFilePath $httpSigningConfiguration.KeyFilePath ` + -DataToSign $signatureHashString ` + -HashAlgorithmName $httpSigningConfiguration.HashAlgorithm ` + -KeyPassPhrase $httpSigningConfiguration.KeyPassPhrase + } + #Deprecated + <#$cryptographicScheme = Get-CryptographicScheme -SigningAlgorithm $httpSigningConfiguration.SigningAlgorithm ` + -HashAlgorithm $httpSigningConfiguration.HashAlgorithm + #> + $cryptographicScheme = "hs2019" + $authorizationHeaderValue = [string]::Format("Signature keyId=""{0}"",algorithm=""{1}""", + $httpSigningConfiguration.KeyId, $cryptographicScheme) + + if ($HttpSignatureHeader.ContainsKey($HEADER_CREATED)) { + $authorizationHeaderValue += [string]::Format(",created={0}", $HttpSignatureHeader[$HEADER_CREATED]) + } + + if ($HttpSignatureHeader.ContainsKey($HEADER_EXPIRES)) { + $authorizationHeaderValue += [string]::Format(",expires={0}", $HttpSignatureHeader[$HEADER_EXPIRES]) + } + + $authorizationHeaderValue += [string]::Format(",headers=""{0}"",signature=""{1}""", + $headersKeysString , $headerSignatureStr) + + $HttpSignedRequestHeader[$HEADER_AUTHORIZATION] = $authorizationHeaderValue + return $HttpSignedRequestHeader +} + +<# +.SYNOPSIS + Gets the RSA signature + +.DESCRIPTION + Gets the RSA signature for the http signing +.PARAMETER PrivateKeyFilePath + Specify the API key file path +.PARAMETER DataToSign + Specify the data to sign +.PARAMETER HashAlgorithmName + HashAlgorithm to calculate the hash +.PARAMETER KeyPassPhrase + KeyPassPhrase for the encrypted key +.OUTPUTS + Base64String +#> +function Get-RSASignature { + Param( + [string]$PrivateKeyFilePath, + [byte[]]$DataToSign, + [string]$HashAlgorithmName, + [string]$SigningAlgorithm, + [securestring]$KeyPassPhrase + ) + try { + + if ($hashAlgorithmName -eq "sha256") { + $hashAlgo = [System.Security.Cryptography.HashAlgorithmName]::SHA256 + } elseif ($hashAlgorithmName -eq "sha512") { + $hashAlgo = [System.Security.Cryptography.HashAlgorithmName]::SHA512 + } + + if ($PSVersionTable.PSVersion.Major -ge 7) { + $ecKeyHeader = "-----BEGIN RSA PRIVATE KEY-----" + $ecKeyFooter = "-----END RSA PRIVATE KEY-----" + $keyStr = Get-Content -Path $PrivateKeyFilePath -Raw + $ecKeyBase64String = $keyStr.Replace($ecKeyHeader, "").Replace($ecKeyFooter, "").Trim() + $keyBytes = [System.Convert]::FromBase64String($ecKeyBase64String) + $rsa = [System.Security.Cryptography.RSA]::Create() + [int]$bytCount = 0 + $rsa.ImportRSAPrivateKey($keyBytes, [ref] $bytCount) + + if ($SigningAlgorithm -eq "RSASSA-PSS") { + $signedBytes = $rsa.SignHash($DataToSign, $hashAlgo, [System.Security.Cryptography.RSASignaturePadding]::Pss) + } else { + $signedBytes = $rsa.SignHash($DataToSign, $hashAlgo, [System.Security.Cryptography.RSASignaturePadding]::Pkcs1) + } + } else { + $rsa_provider_path = Join-Path -Path $PSScriptRoot -ChildPath "RSAEncryptionProvider.cs" + $rsa_provider_sourceCode = Get-Content -Path $rsa_provider_path -Raw + Add-Type -TypeDefinition $rsa_provider_sourceCode + + [System.Security.Cryptography.RSA]$rsa = [RSAEncryption.RSAEncryptionProvider]::GetRSAProviderFromPemFile($PrivateKeyFilePath, $KeyPassPhrase) + + if ($SigningAlgorithm -eq "RSASSA-PSS") { + throw "$SigningAlgorithm is not supported on $($PSVersionTable.PSVersion)" + } else { + $signedBytes = $rsa.SignHash($DataToSign, $hashAlgo, [System.Security.Cryptography.RSASignaturePadding]::Pkcs1) + } + } + + $signedString = [Convert]::ToBase64String($signedBytes) + return $signedString + } catch { + throw $_ + } +} + +<# +.SYNOPSIS + Gets the ECDSA signature + +.DESCRIPTION + Gets the ECDSA signature for the http signing +.PARAMETER PrivateKeyFilePath + Specify the API key file path +.PARAMETER DataToSign + Specify the data to sign +.PARAMETER HashAlgorithmName + HashAlgorithm to calculate the hash +.PARAMETER KeyPassPhrase + KeyPassPhrase for the encrypted key +.OUTPUTS + Base64String +#> +function Get-ECDSASignature { + param( + [Parameter(Mandatory = $true)] + [string]$ECKeyFilePath, + [Parameter(Mandatory = $true)] + [byte[]]$DataToSign, + [Parameter(Mandatory = $false)] + [String]$HashAlgorithmName, + [Parameter(Mandatory = $false)] + [securestring]$KeyPassPhrase + ) + if (!(Test-Path -Path $ECKeyFilePath)) { + throw "key file path does not exist." + } + + if ($PSVersionTable.PSVersion.Major -lt 7) { + throw "ECDSA key is not supported on PowerShell version $($PSVersionTable.PSVersion), Use PowerShell v7.0 and above" + } + + $ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----" + $ecKeyFooter = "-----END EC PRIVATE KEY-----" + $keyStr = Get-Content -Path $ECKeyFilePath -Raw + $ecKeyBase64String = $keyStr.Replace($ecKeyHeader, "").Replace($ecKeyFooter, "").Trim() + $keyBytes = [System.Convert]::FromBase64String($ecKeyBase64String) + $ecdsa = [System.Security.Cryptography.ECDsa]::Create() + + [int]$bytCount =0 + if (![string]::IsNullOrEmpty($KeyPassPhrase)) { + $ecdsa.ImportEncryptedPkcs8PrivateKey($KeyPassPhrase,$keyBytes,[ref]$bytCount) + } else { + $ecdsa.ImportPkcs8PrivateKey($keyBytes,[ref]$bytCount) + } + + $signedBytes = $ecdsa.SignHash($DataToSign) + $derBytes = ConvertTo-ECDSAANS1Format -RawBytes $signedBytes + $signedString = [System.Convert]::ToBase64String($derBytes) + return $signedString +} + +<# +.Synopsis + Gets the hash of string. +.Description + Gets the hash of string +.Parameter String + Specifies the string to calculate the hash +.Parameter HashName + Specifies the hash name to calculate the hash, Accepted values are "SHA1", "SHA256" and "SHA512" + It is recommended not to use "SHA1" to calculate the Hash +.Outputs + String +#> +Function Get-StringHash { + param( + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string]$String, + [Parameter(Mandatory = $true)] + [ValidateSet("SHA1", "SHA256", "SHA512")] + $HashName + ) + $hashAlgorithm = [System.Security.Cryptography.HashAlgorithm]::Create($HashName) + $hashAlgorithm.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($String)) +} + +<# +.Synopsis + Gets the Unix time. +.Description + Gets the Unix time +.Parameter Date + Specifies the date to calculate the unix time +.Parameter ToTalTime + Specifies the total time , Accepted values are "TotalDays", "TotalHours", "TotalMinutes", "TotalSeconds" and "TotalMilliseconds" +.Outputs +Integer +#> +function Get-UnixTime { + param( + [Parameter(Mandatory = $true)] + [DateTime]$Date, + [Parameter(Mandatory = $false)] + [ValidateSet("TotalDays", "TotalHours", "TotalMinutes", "TotalSeconds", "TotalMilliseconds")] + [string]$TotalTime = "TotalSeconds" + ) + $date1 = Get-Date -Date "01/01/1970" + $timespan = New-TimeSpan -Start $date1 -End $Date + switch ($TotalTime) { + "TotalDays" { [int]$timespan.TotalDays } + "TotalHours" { [int]$timespan.TotalHours } + "TotalMinutes" { [int]$timespan.TotalMinutes } + "TotalSeconds" { [int]$timespan.TotalSeconds } + "TotalMilliseconds" { [int]$timespan.TotalMilliseconds } + } +} + +function Get-CryptographicScheme { + param( + [Parameter(Mandatory = $true)] + [string]$SigningAlgorithm, + [Parameter(Mandatory = $true)] + [string]$HashAlgorithm + ) + $rsaSignatureType = @("RSASSA-PKCS1-v1_5", "RSASSA-PSS") + $SigningAlgorithm = $null + if ($rsaSignatureType -contains $SigningAlgorithm) { + switch ($HashAlgorithm) { + "sha256" { $SigningAlgorithm = "rsa-sha256" } + "sha512" { $SigningAlgorithm = "rsa-sha512" } + } + } + return $SigningAlgorithm +} + +<# +.Synopsis + Gets the key type from the pem file. +.Description + Gets the key type from the pem file. +.Parameter KeyFilePath + Specifies the key file path (pem file) +.Outputs +String +#> +function Get-KeyTypeFromFile { + param( + [Parameter(Mandatory = $true)] + [string]$KeyFilePath + ) + + if (-not(Test-Path -Path $KeyFilePath)) { + throw "Key file path does not exist." + } + $ecPrivateKeyHeader = "BEGIN EC PRIVATE KEY" + $ecPrivateKeyFooter = "END EC PRIVATE KEY" + $rsaPrivateKeyHeader = "BEGIN RSA PRIVATE KEY" + $rsaPrivateFooter = "END RSA PRIVATE KEY" + $pkcs8Header = "BEGIN PRIVATE KEY" + $pkcs8Footer = "END PRIVATE KEY" + $keyType = $null + $key = Get-Content -Path $KeyFilePath + + if ($key[0] -match $rsaPrivateKeyHeader -and $key[$key.Length - 1] -match $rsaPrivateFooter) { + $KeyType = "RSA" + } elseif ($key[0] -match $ecPrivateKeyHeader -and $key[$key.Length - 1] -match $ecPrivateKeyFooter) { + $keyType = "EC" + } elseif ($key[0] -match $ecPrivateKeyHeader -and $key[$key.Length - 1] -match $ecPrivateKeyFooter) { + <#this type of key can hold many type different types of private key, but here due lack of pem header + Considering this as EC key + #> + #TODO :- update the key based on oid + $keyType = "EC" + } else { + throw "Either the key is invalid or key is not supported" + } + return $keyType +} + + +<# +.Synopsis + Converts sequence of R and S bytes to ANS1 format for ECDSASignature. +.Description + Converts sequence of R and S bytes to ANS1 format for ECDSASignature. +.Parameter RawBytes[] + Specifies the R and S bytes of ECDSA signature. +.Outputs + Byte[] +#> +function ConvertTo-ECDSAANS1Format{ + Param( + [Parameter(Mandatory = $true)] + [byte[]]$RawBytes + ) + + $derLength = 68 #default length for ECDSA code signing bit 0x44 + $rbytesLength = 32 #R length 0x20 + $sbytesLength = 32 #S length 0x20 + [byte[]]$rBytes = $signedBytes[0..31] + [byte[]]$sBytes = $signedBytes[32..63] + + if($rBytes[0] -gt 0x7F){ + $derLength++ + $rbytesLength++ + $rBytes = [byte[]]@(0x00) + $rBytes + } + + if($sBytes[0] -gt 0x7F){ + $derLength++ + $sbytesLength++ + $sBytes = [byte[]]@(0x00) + $sBytes + } + + [byte[]]$derBytes = @() + + $derBytes += 48 # start of the sequence 0x30 + $derBytes += $derLength # total length r length, type and r bytes + + $derBytes += 2 # tag for integer + $derBytes += $rbytesLength # length of r + $derBytes += $rBytes + + $derBytes += 2 #tag for integer + $derBytes += $sbytesLength #length of s + $derBytes += $sBytes + return $derBytes +} \ No newline at end of file diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/Out-DebugParameter.ps1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/Out-DebugParameter.ps1 new file mode 100644 index 000000000000..68c37a04ceed --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/Out-DebugParameter.ps1 @@ -0,0 +1,45 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.Synopsis + Helper function to format debug parameter output. +.Example + $PSBoundParameters | Out-DebugParameter | Write-Debug +#> +function Out-DebugParameter { + [CmdletBinding()] + Param ( + [Parameter(ValueFromPipeline = $true, Mandatory = $true)] + [AllowEmptyCollection()] + $InputObject + ) + + Begin { + $CommonParameters = Get-CommonParameters + } + + Process { + $InputObject.GetEnumerator() | Where-Object { + $CommonParameters -notcontains $_.Key + } | Format-Table -AutoSize -Property ( + @{ + Name = 'Parameter' + Expression = {$_.Key} + }, + @{ + Name = 'Value' + Expression = {$_.Value} + } + ) | Out-String -Stream | ForEach-Object { + if ($_.Trim()) { + $_ + } + } + } +} diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/RSAEncryptionProvider.cs b/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/RSAEncryptionProvider.cs new file mode 100644 index 000000000000..e4783e6b17dd --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/Private/RSAEncryptionProvider.cs @@ -0,0 +1,354 @@ +/* + * Echo Server API + * + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * Generated by: https://github.com/openapitools/openapi-generator.git + */ +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Runtime.InteropServices; +using System.Security; +using System.Security.Cryptography; +using System.Text; + +namespace RSAEncryption +{ + /// + /// A RSA enccryption provider. + /// + public class RSAEncryptionProvider + { + /// + /// Get the RSA provider from the PEM file. + /// + /// PEM file. + /// Key pass phrase. + /// Get an instance of RSACryptoServiceProvider. + public static RSACryptoServiceProvider GetRSAProviderFromPemFile(String pemfile,SecureString keyPassPhrase = null) + { + const String pempubheader = "-----BEGIN PUBLIC KEY-----"; + const String pempubfooter = "-----END PUBLIC KEY-----"; + bool isPrivateKeyFile = true; + byte[] pemkey = null; + + if (!File.Exists(pemfile)) + { + throw new Exception("private key file does not exist."); + } + string pemstr = File.ReadAllText(pemfile).Trim(); + + if (pemstr.StartsWith(pempubheader) && pemstr.EndsWith(pempubfooter)) + { + isPrivateKeyFile = false; + } + + if (isPrivateKeyFile) + { + pemkey = ConvertPrivateKeyToBytes(pemstr,keyPassPhrase); + if (pemkey == null) + { + return null; + } + return DecodeRSAPrivateKey(pemkey); + } + return null ; + } + + /// + /// Convert the private key to bytes. + /// + /// Private key. + /// Key pass phrase. + /// The private key in the form of bytes. + static byte[] ConvertPrivateKeyToBytes(String instr, SecureString keyPassPhrase = null) + { + const String pemprivheader = "-----BEGIN RSA PRIVATE KEY-----"; + const String pemprivfooter = "-----END RSA PRIVATE KEY-----"; + String pemstr = instr.Trim(); + byte[] binkey; + + if (!pemstr.StartsWith(pemprivheader) || !pemstr.EndsWith(pemprivfooter)) + { + return null; + } + + StringBuilder sb = new StringBuilder(pemstr); + sb.Replace(pemprivheader, ""); + sb.Replace(pemprivfooter, ""); + String pvkstr = sb.ToString().Trim(); + + try + { // if there are no PEM encryption info lines, this is an UNencrypted PEM private key + binkey = Convert.FromBase64String(pvkstr); + return binkey; + } + catch (System.FormatException) + { + StringReader str = new StringReader(pvkstr); + + //-------- read PEM encryption info. lines and extract salt ----- + if (!str.ReadLine().StartsWith("Proc-Type: 4,ENCRYPTED")) + { + return null; + } + String saltline = str.ReadLine(); + if (!saltline.StartsWith("DEK-Info: DES-EDE3-CBC,")) + { + return null; + } + String saltstr = saltline.Substring(saltline.IndexOf(",") + 1).Trim(); + byte[] salt = new byte[saltstr.Length / 2]; + for (int i = 0; i < salt.Length; i++) + { + salt[i] = Convert.ToByte(saltstr.Substring(i * 2, 2), 16); + } + if (str.ReadLine() != "") + { + return null; + } + + //------ remaining b64 data is encrypted RSA key ---- + String encryptedstr = str.ReadToEnd(); + + try + { //should have b64 encrypted RSA key now + binkey = Convert.FromBase64String(encryptedstr); + } + catch (System.FormatException) + { //data is not in base64 format + return null; + } + + byte[] deskey = GetEncryptedKey(salt, keyPassPhrase, 1, 2); // count=1 (for OpenSSL implementation); 2 iterations to get at least 24 bytes + if (deskey == null) + { + return null; + } + + //------ Decrypt the encrypted 3des-encrypted RSA private key ------ + byte[] rsakey = DecryptKey(binkey, deskey, salt); //OpenSSL uses salt value in PEM header also as 3DES IV + return rsakey; + } + } + + /// + /// Decode the RSA private key. + /// + /// Private key. + /// An instance of RSACryptoServiceProvider. + public static RSACryptoServiceProvider DecodeRSAPrivateKey(byte[] privkey) + { + byte[] bytesModules, bytesE, bytesD, bytesP, bytesQ, bytesDp, bytesDq, bytesIq; + + // --------- Set up stream to decode the asn.1 encoded RSA private key ------ + MemoryStream mem = new MemoryStream(privkey); + BinaryReader binr = new BinaryReader(mem); //wrap Memory Stream with BinaryReader for easy reading + byte bt = 0; + ushort twobytes = 0; + int elems = 0; + try + { + twobytes = binr.ReadUInt16(); + if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81) + { + binr.ReadByte(); //advance 1 byte + } + else if (twobytes == 0x8230) + { + binr.ReadInt16(); //advance 2 bytes + } + else + { + return null; + } + + twobytes = binr.ReadUInt16(); + if (twobytes != 0x0102) //version number + { + return null; + } + bt = binr.ReadByte(); + if (bt != 0x00) + { + return null; + } + + //------ all private key components are Integer sequences ---- + elems = GetIntegerSize(binr); + bytesModules = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + bytesE = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + bytesD = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + bytesP = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + bytesQ = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + bytesDp = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + bytesDq = binr.ReadBytes(elems); + + elems = GetIntegerSize(binr); + bytesIq = binr.ReadBytes(elems); + + // ------- create RSACryptoServiceProvider instance and initialize with public key ----- + RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); + RSAParameters RSAparams = new RSAParameters(); + RSAparams.Modulus = bytesModules; + RSAparams.Exponent = bytesE; + RSAparams.D = bytesD; + RSAparams.P = bytesP; + RSAparams.Q = bytesQ; + RSAparams.DP = bytesDp; + RSAparams.DQ = bytesDq; + RSAparams.InverseQ = bytesIq; + rsa.ImportParameters(RSAparams); + return rsa; + } + catch (Exception) + { + return null; + } + finally + { + binr.Close(); + } + } + + private static int GetIntegerSize(BinaryReader binr) + { + byte bt = 0; + byte lowbyte = 0x00; + byte highbyte = 0x00; + int count = 0; + bt = binr.ReadByte(); + if (bt != 0x02) //expect integer + { + return 0; + } + bt = binr.ReadByte(); + + if (bt == 0x81) + { + count = binr.ReadByte(); // data size in next byte + } + else if (bt == 0x82) + { + highbyte = binr.ReadByte(); // data size in next 2 bytes + lowbyte = binr.ReadByte(); + byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; + count = BitConverter.ToInt32(modint, 0); + } + else + { + count = bt; // we already have the data size + } + while (binr.ReadByte() == 0x00) + { //remove high order zeros in data + count -= 1; + } + binr.BaseStream.Seek(-1, SeekOrigin.Current); + //last ReadByte wasn't a removed zero, so back up a byte + return count; + } + + /// + /// Get the encrypted key. + /// + /// Random bytes to be added. + /// Password. + /// Count. + /// Miter. + /// Decrypted key. + static byte[] GetEncryptedKey(byte[] salt, SecureString secpswd, int count, int miter) + { + IntPtr unmanagedPswd = IntPtr.Zero; + const int HASHLENGTH = 16; //MD5 bytes + byte[] keymaterial = new byte[HASHLENGTH * miter]; //to store concatenated Mi hashed results + + byte[] psbytes = new byte[secpswd.Length]; + unmanagedPswd = Marshal.SecureStringToGlobalAllocAnsi(secpswd); + Marshal.Copy(unmanagedPswd, psbytes, 0, psbytes.Length); + Marshal.ZeroFreeGlobalAllocAnsi(unmanagedPswd); + + // --- concatenate salt and pswd bytes into fixed data array --- + byte[] data00 = new byte[psbytes.Length + salt.Length]; + Array.Copy(psbytes, data00, psbytes.Length); //copy the pswd bytes + Array.Copy(salt, 0, data00, psbytes.Length, salt.Length); //concatenate the salt bytes + + // ---- do multi-hashing and concatenate results D1, D2 ... into keymaterial bytes ---- + MD5 md5 = new MD5CryptoServiceProvider(); + byte[] result = null; + byte[] hashtarget = new byte[HASHLENGTH + data00.Length]; //fixed length initial hashtarget + + for (int j = 0; j < miter; j++) + { + // ---- Now hash consecutively for count times ------ + if (j == 0) + { + result = data00; //initialize + } + else + { + Array.Copy(result, hashtarget, result.Length); + Array.Copy(data00, 0, hashtarget, result.Length, data00.Length); + result = hashtarget; + } + + for (int i = 0; i < count; i++) + { + result = md5.ComputeHash(result); + } + Array.Copy(result, 0, keymaterial, j * HASHLENGTH, result.Length); //concatenate to keymaterial + } + byte[] deskey = new byte[24]; + Array.Copy(keymaterial, deskey, deskey.Length); + + Array.Clear(psbytes, 0, psbytes.Length); + Array.Clear(data00, 0, data00.Length); + Array.Clear(result, 0, result.Length); + Array.Clear(hashtarget, 0, hashtarget.Length); + Array.Clear(keymaterial, 0, keymaterial.Length); + return deskey; + } + + /// + /// Decrypt the key. + /// + /// Cipher data. + /// Key to decrypt. + /// Initialization vector. + /// Decrypted key. + static byte[] DecryptKey(byte[] cipherData, byte[] desKey, byte[] IV) + { + MemoryStream memst = new MemoryStream(); + TripleDES alg = TripleDES.Create(); + alg.Key = desKey; + alg.IV = IV; + try + { + CryptoStream cs = new CryptoStream(memst, alg.CreateDecryptor(), CryptoStreamMode.Write); + cs.Write(cipherData, 0, cipherData.Length); + cs.Close(); + } + catch (Exception) + { + return null; + } + byte[] decryptedData = memst.ToArray(); + return decryptedData; + } + } +} diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/en-US/about_PSOpenAPITools.help.txt b/samples/client/echo_api/powershell/src/PSOpenAPITools/en-US/about_PSOpenAPITools.help.txt new file mode 100644 index 000000000000..91395c726269 --- /dev/null +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/en-US/about_PSOpenAPITools.help.txt @@ -0,0 +1,19 @@ +PSTOPIC + about_PSOpenAPITools + +SHORT DESCRIPTION + PSOpenAPITools - the PowerShell module for the Echo Server API + +LONG DESCRIPTION + Echo Server API + + This PowerShell module is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + + - API version: 0.1.0 + - SDK version: 0.1.2 + - Build package: org.openapitools.codegen.languages.PowerShellClientCodegen + + Frameworks supported: + + * PowerShell 6.2 or later + * .NET 4.0 or later diff --git a/samples/client/echo_api/powershell/tests/Api/AuthApi.Tests.ps1 b/samples/client/echo_api/powershell/tests/Api/AuthApi.Tests.ps1 new file mode 100644 index 000000000000..fb4b6a144d8a --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Api/AuthApi.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'AuthApi' { + Context 'Test-AuthHttpBasic' { + It 'Test Test-AuthHttpBasic' { + #$TestResult = Test-AuthHttpBasic + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + +} diff --git a/samples/client/echo_api/powershell/tests/Api/BodyApi.Tests.ps1 b/samples/client/echo_api/powershell/tests/Api/BodyApi.Tests.ps1 new file mode 100644 index 000000000000..4829c660719c --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Api/BodyApi.Tests.ps1 @@ -0,0 +1,74 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'BodyApi' { + Context 'Test-BinaryGif' { + It 'Test Test-BinaryGif' { + #$TestResult = Test-BinaryGif + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-BodyApplicationOctetstreamBinary' { + It 'Test Test-BodyApplicationOctetstreamBinary' { + #$TestResult = Test-BodyApplicationOctetstreamBinary -Body "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-BodyMultipartFormdataArrayOfBinary' { + It 'Test Test-BodyMultipartFormdataArrayOfBinary' { + #$TestResult = Test-BodyMultipartFormdataArrayOfBinary -Files "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-EchoBodyFreeFormObjectResponseString' { + It 'Test Test-EchoBodyFreeFormObjectResponseString' { + #$TestResult = Test-EchoBodyFreeFormObjectResponseString -Body "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-EchoBodyPet' { + It 'Test Test-EchoBodyPet' { + #$TestResult = Test-EchoBodyPet -Pet "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-EchoBodyPetResponseString' { + It 'Test Test-EchoBodyPetResponseString' { + #$TestResult = Test-EchoBodyPetResponseString -Pet "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-EchoBodyTagResponseString' { + It 'Test Test-EchoBodyTagResponseString' { + #$TestResult = Test-EchoBodyTagResponseString -Tag "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-EchoBodyAllOfPet' { + It 'Test Test-EchoBodyAllOfPet' { + #$TestResult = Test-EchoBodyAllOfPet -Pet "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + +} diff --git a/samples/client/echo_api/powershell/tests/Api/FormApi.Tests.ps1 b/samples/client/echo_api/powershell/tests/Api/FormApi.Tests.ps1 new file mode 100644 index 000000000000..db830207c63e --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Api/FormApi.Tests.ps1 @@ -0,0 +1,26 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'FormApi' { + Context 'Test-FormIntegerBooleanString' { + It 'Test Test-FormIntegerBooleanString' { + #$TestResult = Test-FormIntegerBooleanString -IntegerForm "TEST_VALUE" -BooleanForm "TEST_VALUE" -StringForm "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-FormOneof' { + It 'Test Test-FormOneof' { + #$TestResult = Test-FormOneof -Form1 "TEST_VALUE" -Form2 "TEST_VALUE" -Form3 "TEST_VALUE" -Form4 "TEST_VALUE" -Id "TEST_VALUE" -Name "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + +} diff --git a/samples/client/echo_api/powershell/tests/Api/HeaderApi.Tests.ps1 b/samples/client/echo_api/powershell/tests/Api/HeaderApi.Tests.ps1 new file mode 100644 index 000000000000..abb9ffbc5b01 --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Api/HeaderApi.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'HeaderApi' { + Context 'Test-HeaderIntegerBooleanStringEnums' { + It 'Test Test-HeaderIntegerBooleanStringEnums' { + #$TestResult = Test-HeaderIntegerBooleanStringEnums -IntegerHeader "TEST_VALUE" -BooleanHeader "TEST_VALUE" -StringHeader "TEST_VALUE" -EnumNonrefStringHeader "TEST_VALUE" -EnumRefStringHeader "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + +} diff --git a/samples/client/echo_api/powershell/tests/Api/PathApi.Tests.ps1 b/samples/client/echo_api/powershell/tests/Api/PathApi.Tests.ps1 new file mode 100644 index 000000000000..33ea3411b713 --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Api/PathApi.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'PathApi' { + Context 'Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath' { + It 'Test Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath' { + #$TestResult = Test-sPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath -PathString "TEST_VALUE" -PathInteger "TEST_VALUE" -EnumNonrefStringPath "TEST_VALUE" -EnumRefStringPath "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + +} diff --git a/samples/client/echo_api/powershell/tests/Api/QueryApi.Tests.ps1 b/samples/client/echo_api/powershell/tests/Api/QueryApi.Tests.ps1 new file mode 100644 index 000000000000..ebbdd643d0be --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Api/QueryApi.Tests.ps1 @@ -0,0 +1,74 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'QueryApi' { + Context 'Test-EnumRefString' { + It 'Test Test-EnumRefString' { + #$TestResult = Test-EnumRefString -EnumNonrefStringQuery "TEST_VALUE" -EnumRefStringQuery "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-QueryDatetimeDateString' { + It 'Test Test-QueryDatetimeDateString' { + #$TestResult = Test-QueryDatetimeDateString -DatetimeQuery "TEST_VALUE" -DateQuery "TEST_VALUE" -StringQuery "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-QueryIntegerBooleanString' { + It 'Test Test-QueryIntegerBooleanString' { + #$TestResult = Test-QueryIntegerBooleanString -IntegerQuery "TEST_VALUE" -BooleanQuery "TEST_VALUE" -StringQuery "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-QueryStyleDeepObjectExplodeTrueObject' { + It 'Test Test-QueryStyleDeepObjectExplodeTrueObject' { + #$TestResult = Test-QueryStyleDeepObjectExplodeTrueObject -QueryObject "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-QueryStyleDeepObjectExplodeTrueObjectAllOf' { + It 'Test Test-QueryStyleDeepObjectExplodeTrueObjectAllOf' { + #$TestResult = Test-QueryStyleDeepObjectExplodeTrueObjectAllOf -QueryObject "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-QueryStyleFormExplodeTrueArrayString' { + It 'Test Test-QueryStyleFormExplodeTrueArrayString' { + #$TestResult = Test-QueryStyleFormExplodeTrueArrayString -QueryObject "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-QueryStyleFormExplodeTrueObject' { + It 'Test Test-QueryStyleFormExplodeTrueObject' { + #$TestResult = Test-QueryStyleFormExplodeTrueObject -QueryObject "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + + Context 'Test-QueryStyleFormExplodeTrueObjectAllOf' { + It 'Test Test-QueryStyleFormExplodeTrueObjectAllOf' { + #$TestResult = Test-QueryStyleFormExplodeTrueObjectAllOf -QueryObject "TEST_VALUE" + #$TestResult | Should -BeOfType TODO + #$TestResult.property | Should -Be 0 + } + } + +} diff --git a/samples/client/echo_api/powershell/tests/Model/Bird.Tests.ps1 b/samples/client/echo_api/powershell/tests/Model/Bird.Tests.ps1 new file mode 100644 index 000000000000..d9e7a87e3406 --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Model/Bird.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'Bird' { + Context 'Bird' { + It 'Initialize-Bird' { + # a simple test to create an object + #$NewObject = Initialize-Bird -Size "TEST_VALUE" -Color "TEST_VALUE" + #$NewObject | Should -BeOfType Bird + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/echo_api/powershell/tests/Model/Category.Tests.ps1 b/samples/client/echo_api/powershell/tests/Model/Category.Tests.ps1 new file mode 100644 index 000000000000..578a4feaee64 --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Model/Category.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'Category' { + Context 'Category' { + It 'Initialize-Category' { + # a simple test to create an object + #$NewObject = Initialize-Category -Id "TEST_VALUE" -Name "TEST_VALUE" + #$NewObject | Should -BeOfType Category + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/echo_api/powershell/tests/Model/DataQuery.Tests.ps1 b/samples/client/echo_api/powershell/tests/Model/DataQuery.Tests.ps1 new file mode 100644 index 000000000000..909513d04a3f --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Model/DataQuery.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'DataQuery' { + Context 'DataQuery' { + It 'Initialize-DataQuery' { + # a simple test to create an object + #$NewObject = Initialize-DataQuery -Id "TEST_VALUE" -Outcomes "TEST_VALUE" -Suffix "TEST_VALUE" -Text "TEST_VALUE" -Date "TEST_VALUE" + #$NewObject | Should -BeOfType DataQuery + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/echo_api/powershell/tests/Model/DefaultValue.Tests.ps1 b/samples/client/echo_api/powershell/tests/Model/DefaultValue.Tests.ps1 new file mode 100644 index 000000000000..e8c7191f70e7 --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Model/DefaultValue.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'DefaultValue' { + Context 'DefaultValue' { + It 'Initialize-DefaultValue' { + # a simple test to create an object + #$NewObject = Initialize-DefaultValue -ArrayStringEnumRefDefault "TEST_VALUE" -ArrayStringEnumDefault "TEST_VALUE" -ArrayStringDefault "TEST_VALUE" -ArrayIntegerDefault "TEST_VALUE" -ArrayString "TEST_VALUE" -ArrayStringNullable "TEST_VALUE" -ArrayStringExtensionNullable "TEST_VALUE" -StringNullable "TEST_VALUE" + #$NewObject | Should -BeOfType DefaultValue + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/echo_api/powershell/tests/Model/NumberPropertiesOnly.Tests.ps1 b/samples/client/echo_api/powershell/tests/Model/NumberPropertiesOnly.Tests.ps1 new file mode 100644 index 000000000000..c73cecf35759 --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Model/NumberPropertiesOnly.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'NumberPropertiesOnly' { + Context 'NumberPropertiesOnly' { + It 'Initialize-NumberPropertiesOnly' { + # a simple test to create an object + #$NewObject = Initialize-NumberPropertiesOnly -Number "TEST_VALUE" -Float "TEST_VALUE" -Double "TEST_VALUE" + #$NewObject | Should -BeOfType NumberPropertiesOnly + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/echo_api/powershell/tests/Model/Pet.Tests.ps1 b/samples/client/echo_api/powershell/tests/Model/Pet.Tests.ps1 new file mode 100644 index 000000000000..53a5c902141c --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Model/Pet.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'Pet' { + Context 'Pet' { + It 'Initialize-Pet' { + # a simple test to create an object + #$NewObject = Initialize-Pet -Id "TEST_VALUE" -Name "TEST_VALUE" -Category "TEST_VALUE" -PhotoUrls "TEST_VALUE" -Tags "TEST_VALUE" -Status "TEST_VALUE" + #$NewObject | Should -BeOfType Pet + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/echo_api/powershell/tests/Model/Query.Tests.ps1 b/samples/client/echo_api/powershell/tests/Model/Query.Tests.ps1 new file mode 100644 index 000000000000..9b67d81c7681 --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Model/Query.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'Query' { + Context 'Query' { + It 'Initialize-Query' { + # a simple test to create an object + #$NewObject = Initialize-Query -Id "TEST_VALUE" -Outcomes "TEST_VALUE" + #$NewObject | Should -BeOfType Query + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/echo_api/powershell/tests/Model/StringEnumRef.Tests.ps1 b/samples/client/echo_api/powershell/tests/Model/StringEnumRef.Tests.ps1 new file mode 100644 index 000000000000..e13f82b9c5ab --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Model/StringEnumRef.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'StringEnumRef' { + Context 'StringEnumRef' { + It 'Initialize-StringEnumRef' { + # a simple test to create an object + #$NewObject = Initialize-StringEnumRef + #$NewObject | Should -BeOfType StringEnumRef + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/echo_api/powershell/tests/Model/Tag.Tests.ps1 b/samples/client/echo_api/powershell/tests/Model/Tag.Tests.ps1 new file mode 100644 index 000000000000..c0100be827ac --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Model/Tag.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'Tag' { + Context 'Tag' { + It 'Initialize-Tag' { + # a simple test to create an object + #$NewObject = Initialize-Tag -Id "TEST_VALUE" -Name "TEST_VALUE" + #$NewObject | Should -BeOfType Tag + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/echo_api/powershell/tests/Model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.Tests.ps1 b/samples/client/echo_api/powershell/tests/Model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.Tests.ps1 new file mode 100644 index 000000000000..04997034c0a6 --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter' { + Context 'TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter' { + It 'Initialize-TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter' { + # a simple test to create an object + #$NewObject = Initialize-TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter -Size "TEST_VALUE" -Color "TEST_VALUE" -Id "TEST_VALUE" -Name "TEST_VALUE" + #$NewObject | Should -BeOfType TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/echo_api/powershell/tests/Model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.Tests.ps1 b/samples/client/echo_api/powershell/tests/Model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.Tests.ps1 new file mode 100644 index 000000000000..6bfaed484b8e --- /dev/null +++ b/samples/client/echo_api/powershell/tests/Model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.Tests.ps1 @@ -0,0 +1,18 @@ +# +# Echo Server API +# Echo Server API +# Version: 0.1.0 +# Contact: team@openapitools.org +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSOpenAPITools' -name 'TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter' { + Context 'TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter' { + It 'Initialize-TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter' { + # a simple test to create an object + #$NewObject = Initialize-TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter -Values "TEST_VALUE" + #$NewObject | Should -BeOfType TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/petstore/powershell/README.md b/samples/client/petstore/powershell/README.md index 57c663aae01d..e02ad9f8eb59 100644 --- a/samples/client/petstore/powershell/README.md +++ b/samples/client/petstore/powershell/README.md @@ -196,7 +196,7 @@ Authentication schemes defined for the API: - **Type**: API key -- **API key parameter name**: api_key +- **API key parameter name**: api_key_name - **Location**: HTTP header @@ -204,7 +204,7 @@ Authentication schemes defined for the API: - **Type**: API key -- **API key parameter name**: api_key_query +- **API key parameter name**: api_key_query_name - **Location**: URL query string diff --git a/samples/client/petstore/powershell/docs/PSFakeClassnameTags123Api.md b/samples/client/petstore/powershell/docs/PSFakeClassnameTags123Api.md index 9da7ec300016..02bfd8628a25 100644 --- a/samples/client/petstore/powershell/docs/PSFakeClassnameTags123Api.md +++ b/samples/client/petstore/powershell/docs/PSFakeClassnameTags123Api.md @@ -21,9 +21,9 @@ To test class name in snake case # general setting of the PowerShell module, e.g. base URL, authentication, etc $Configuration = Get-Configuration # Configure API key authorization: api_key_query -$Configuration.ApiKey.api_key_query = "YOUR_API_KEY" +$Configuration.ApiKey.api_key_query_name = "YOUR_API_KEY" # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -#$Configuration.ApiKeyPrefix.api_key_query = "Bearer" +#$Configuration.ApiKeyPrefix.api_key_query_name = "Bearer" $Client = Initialize-Client -Client "MyClient" # Client | client model diff --git a/samples/client/petstore/powershell/docs/PSPetApi.md b/samples/client/petstore/powershell/docs/PSPetApi.md index 6fc29288adfc..48d7f783ce4c 100644 --- a/samples/client/petstore/powershell/docs/PSPetApi.md +++ b/samples/client/petstore/powershell/docs/PSPetApi.md @@ -253,9 +253,9 @@ Returns a single pet # general setting of the PowerShell module, e.g. base URL, authentication, etc $Configuration = Get-Configuration # Configure API key authorization: api_key -$Configuration.ApiKey.api_key = "YOUR_API_KEY" +$Configuration.ApiKey.api_key_name = "YOUR_API_KEY" # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -#$Configuration.ApiKeyPrefix.api_key = "Bearer" +#$Configuration.ApiKeyPrefix.api_key_name = "Bearer" $PetId = 789 # Int64 | ID of pet to return diff --git a/samples/client/petstore/powershell/docs/PSStoreApi.md b/samples/client/petstore/powershell/docs/PSStoreApi.md index 3d192a300182..2ff14209a049 100644 --- a/samples/client/petstore/powershell/docs/PSStoreApi.md +++ b/samples/client/petstore/powershell/docs/PSStoreApi.md @@ -66,9 +66,9 @@ Returns a map of status codes to quantities # general setting of the PowerShell module, e.g. base URL, authentication, etc $Configuration = Get-Configuration # Configure API key authorization: api_key -$Configuration.ApiKey.api_key = "YOUR_API_KEY" +$Configuration.ApiKey.api_key_name = "YOUR_API_KEY" # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -#$Configuration.ApiKeyPrefix.api_key = "Bearer" +#$Configuration.ApiKeyPrefix.api_key_name = "Bearer" # Returns pet inventories by status diff --git a/samples/client/petstore/powershell/src/PSPetstore/Api/PSFakeClassnameTags123Api.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Api/PSFakeClassnameTags123Api.ps1 index 35f1186fcce4..0ffb6cd7f3b3 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Api/PSFakeClassnameTags123Api.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Api/PSFakeClassnameTags123Api.ps1 @@ -63,9 +63,9 @@ function Test-PSClassname { $LocalVarBodyParameter = $Client | ConvertTo-Json -Depth 100 - if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["api_key_query"]) { - $LocalVarQueryParameters['api_key_query'] = $Configuration["ApiKey"]["api_key_query"] - Write-Verbose ("Using API key `api_key_query` in the URL query for authentication in {0}" -f $MyInvocation.MyCommand) + if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["api_key_query_name"]) { + $LocalVarQueryParameters['api_key_query_name'] = $Configuration["ApiKey"]["api_key_query_name"] + Write-Verbose ("Using API key `api_key_query_name` in the URL query for authentication in {0}" -f $MyInvocation.MyCommand) } $LocalVarResult = Invoke-PSApiClient -Method 'PATCH' ` diff --git a/samples/client/petstore/powershell/src/PSPetstore/Api/PSPetApi.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Api/PSPetApi.ps1 index 3542112c914d..e28ffcabca08 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Api/PSPetApi.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Api/PSPetApi.ps1 @@ -405,9 +405,9 @@ function Get-PSPetById { } $LocalVarUri = $LocalVarUri.replace('{petId}', [System.Web.HTTPUtility]::UrlEncode($PetId)) - if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["api_key"]) { - $LocalVarHeaderParameters['api_key'] = $Configuration["ApiKey"]["api_key"] - Write-Verbose ("Using API key 'api_key' in the header for authentication in {0}" -f $MyInvocation.MyCommand) + if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["api_key_name"]) { + $LocalVarHeaderParameters['api_key_name'] = $Configuration["ApiKey"]["api_key_name"] + Write-Verbose ("Using API key 'api_key_name' in the header for authentication in {0}" -f $MyInvocation.MyCommand) } $LocalVarResult = Invoke-PSApiClient -Method 'GET' ` diff --git a/samples/client/petstore/powershell/src/PSPetstore/Api/PSStoreApi.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Api/PSStoreApi.ps1 index a0f88138a48d..40fd1e0c64f6 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Api/PSStoreApi.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Api/PSStoreApi.ps1 @@ -118,9 +118,9 @@ function Get-PSInventory { $LocalVarUri = '/store/inventory' - if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["api_key"]) { - $LocalVarHeaderParameters['api_key'] = $Configuration["ApiKey"]["api_key"] - Write-Verbose ("Using API key 'api_key' in the header for authentication in {0}" -f $MyInvocation.MyCommand) + if ($Configuration["ApiKey"] -and $Configuration["ApiKey"]["api_key_name"]) { + $LocalVarHeaderParameters['api_key_name'] = $Configuration["ApiKey"]["api_key_name"] + Write-Verbose ("Using API key 'api_key_name' in the header for authentication in {0}" -f $MyInvocation.MyCommand) } $LocalVarResult = Invoke-PSApiClient -Method 'GET' ` From c377fdf62d261d1367b2f1637f17fa0a3af22da9 Mon Sep 17 00:00:00 2001 From: Elon Mallin Date: Sun, 12 Nov 2023 17:29:49 +0100 Subject: [PATCH 09/12] Fix powershell client Build.ps1 and *.psm1 error when there is a missing Model folder (#17025) * fix(powershell): make sure paths exists when building and importing module * chore(powershell): update sample psm1 and build.ps1 with path check --- .../src/main/resources/powershell/Build.ps1.mustache | 4 +++- .../main/resources/powershell/Org.OpenAPITools.psm1.mustache | 4 +++- samples/client/petstore/powershell/Build.ps1 | 4 +++- .../client/petstore/powershell/src/PSPetstore/PSPetstore.psm1 | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache b/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache index 6fed374afbda..be74a1180379 100644 --- a/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache +++ b/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache @@ -39,7 +39,9 @@ function Get-FunctionsToExport { } $ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path -$FunctionPath = 'Api', 'Model', 'Client' | ForEach-Object {Join-Path "$ScriptDir\src\{{{packageName}}}\" $_} +$FunctionPath = 'Api', 'Model', 'Client' | Where-Object { + Join-Path "$ScriptDir\src\{{{packageName}}}\" $_ | Test-Path +} | ForEach-Object { Join-Path "$ScriptDir\src\{{{packageName}}}\" $_ } $Manifest = @{ Path = "$ScriptDir\src\{{{packageName}}}\{{{packageName}}}.psd1" diff --git a/modules/openapi-generator/src/main/resources/powershell/Org.OpenAPITools.psm1.mustache b/modules/openapi-generator/src/main/resources/powershell/Org.OpenAPITools.psm1.mustache index 32795eca3763..feb7ee5ec66b 100644 --- a/modules/openapi-generator/src/main/resources/powershell/Org.OpenAPITools.psm1.mustache +++ b/modules/openapi-generator/src/main/resources/powershell/Org.OpenAPITools.psm1.mustache @@ -17,7 +17,9 @@ $Script:Configuration = [System.Collections.HashTable]@{} $Script:CmdletBindingParameters = @('Verbose','Debug','ErrorAction','WarningAction','InformationAction','ErrorVariable','WarningVariable','InformationVariable','OutVariable','OutBuffer','PipelineVariable') -'Api', 'Model', 'Client', 'Private' | Get-ChildItem -Path { +'Api', 'Model', 'Client', 'Private' | Where-Object { + Join-Path $PSScriptRoot $_ | Test-Path +} | Get-ChildItem -Path { Join-Path $PSScriptRoot $_ } -Filter '*.ps1' | ForEach-Object { Write-Debug "Importing file: $($_.BaseName)" diff --git a/samples/client/petstore/powershell/Build.ps1 b/samples/client/petstore/powershell/Build.ps1 index e15418c3aadf..81c67431bdbf 100644 --- a/samples/client/petstore/powershell/Build.ps1 +++ b/samples/client/petstore/powershell/Build.ps1 @@ -45,7 +45,9 @@ function Get-FunctionsToExport { } $ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path -$FunctionPath = 'Api', 'Model', 'Client' | ForEach-Object {Join-Path "$ScriptDir\src\PSPetstore\" $_} +$FunctionPath = 'Api', 'Model', 'Client' | Where-Object { + Join-Path "$ScriptDir\src\PSPetstore\" $_ | Test-Path +} | ForEach-Object { Join-Path "$ScriptDir\src\PSPetstore\" $_ } $Manifest = @{ Path = "$ScriptDir\src\PSPetstore\PSPetstore.psd1" diff --git a/samples/client/petstore/powershell/src/PSPetstore/PSPetstore.psm1 b/samples/client/petstore/powershell/src/PSPetstore/PSPetstore.psm1 index 8b0bd5f780e4..486b345ebc11 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/PSPetstore.psm1 +++ b/samples/client/petstore/powershell/src/PSPetstore/PSPetstore.psm1 @@ -23,7 +23,9 @@ $Script:Configuration = [System.Collections.HashTable]@{} $Script:CmdletBindingParameters = @('Verbose','Debug','ErrorAction','WarningAction','InformationAction','ErrorVariable','WarningVariable','InformationVariable','OutVariable','OutBuffer','PipelineVariable') -'Api', 'Model', 'Client', 'Private' | Get-ChildItem -Path { +'Api', 'Model', 'Client', 'Private' | Where-Object { + Join-Path $PSScriptRoot $_ | Test-Path +} | Get-ChildItem -Path { Join-Path $PSScriptRoot $_ } -Filter '*.ps1' | ForEach-Object { Write-Debug "Importing file: $($_.BaseName)" From f83e4ffb9b35d0f6fd5ee0f2c27e41d32ae7f53c Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 13 Nov 2023 08:55:52 +0800 Subject: [PATCH 10/12] update PS samples --- samples/client/echo_api/powershell/Build.ps1 | 4 +++- .../powershell/src/PSOpenAPITools/PSOpenAPITools.psm1 | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/samples/client/echo_api/powershell/Build.ps1 b/samples/client/echo_api/powershell/Build.ps1 index 49d6a3a92745..f1d1898660c1 100644 --- a/samples/client/echo_api/powershell/Build.ps1 +++ b/samples/client/echo_api/powershell/Build.ps1 @@ -46,7 +46,9 @@ function Get-FunctionsToExport { } $ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path -$FunctionPath = 'Api', 'Model', 'Client' | ForEach-Object {Join-Path "$ScriptDir\src\PSOpenAPITools\" $_} +$FunctionPath = 'Api', 'Model', 'Client' | Where-Object { + Join-Path "$ScriptDir\src\PSOpenAPITools\" $_ | Test-Path +} | ForEach-Object { Join-Path "$ScriptDir\src\PSOpenAPITools\" $_ } $Manifest = @{ Path = "$ScriptDir\src\PSOpenAPITools\PSOpenAPITools.psd1" diff --git a/samples/client/echo_api/powershell/src/PSOpenAPITools/PSOpenAPITools.psm1 b/samples/client/echo_api/powershell/src/PSOpenAPITools/PSOpenAPITools.psm1 index daf04503ba97..5b32c2c0133e 100644 --- a/samples/client/echo_api/powershell/src/PSOpenAPITools/PSOpenAPITools.psm1 +++ b/samples/client/echo_api/powershell/src/PSOpenAPITools/PSOpenAPITools.psm1 @@ -24,7 +24,9 @@ $Script:Configuration = [System.Collections.HashTable]@{} $Script:CmdletBindingParameters = @('Verbose','Debug','ErrorAction','WarningAction','InformationAction','ErrorVariable','WarningVariable','InformationVariable','OutVariable','OutBuffer','PipelineVariable') -'Api', 'Model', 'Client', 'Private' | Get-ChildItem -Path { +'Api', 'Model', 'Client', 'Private' | Where-Object { + Join-Path $PSScriptRoot $_ | Test-Path +} | Get-ChildItem -Path { Join-Path $PSScriptRoot $_ } -Filter '*.ps1' | ForEach-Object { Write-Debug "Importing file: $($_.BaseName)" From 5693eee4e0b5ca4b47ca00fe388b5ebc43df7ec1 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 13 Nov 2023 10:00:55 +0800 Subject: [PATCH 11/12] Fix CircleCI build (#17016) * fix circleci build * add maven opts * remove cache path * clear cache * fix node 0 * use 1024 * skip save cache * restore tests * fix * fix typo * update * clean up pom.xml --- .circleci/config.yml | 75 ++++++------- CI/circle_parallel.sh | 93 +++++++++++----- pom.xml | 239 ------------------------------------------ 3 files changed, 101 insertions(+), 306 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2f05fb9a72ed..71098116b4c3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,54 +57,43 @@ commands: # a reusable command with parameters - run: docker ps -a - run: sleep 30 - run: cat /etc/hosts - # Test - - run: ./mvnw --no-snapshot-updates --quiet clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error + - run: export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m" - run: name: "Setup custom environment variables" command: echo 'export CIRCLE_NODE_INDEX="<>"' >> $BASH_ENV - run: ./CI/circle_parallel.sh # Save dependency cache - - save_cache: - key: source-v2-{{ .Branch }}-{{ .Revision }} - paths: - # This is a broad list of cache paths to include many possible development environments - # You can probably delete some of these entries - - vendor/bundle - - ~/.nvm - - ~/.pyenv - - ~/virtualenvs - - ~/.m2 - - ~/.ivy2 - - ~/.sbt - - ~/.bundle - - ~/.go_workspace - - ~/.gradle - - ~/.cache/bower - - ".git" - - ~/.stack - - /home/circleci/OpenAPITools/openapi-generator/samples/client/petstore/haskell-http-client/.stack-work - - ~/R - # save "default" cache using the key "source-v2-" - - save_cache: - key: source-v2- - paths: - # This is a broad list of cache paths to include many possible development environments - # You can probably delete some of these entries - - vendor/bundle - - ~/.nvm - - ~/.pyenv - - ~/virtualenvs - - ~/.m2 - - ~/.ivy2 - - ~/.sbt - - ~/.bundle - - ~/.go_workspace - - ~/.gradle - - ~/.cache/bower - - ".git" - - ~/.stack - - /home/circleci/OpenAPITools/openapi-generator/samples/client/petstore/haskell-http-client/.stack-work - - ~/R + #- save_cache: + # key: source-v2-{{ .Branch }}-{{ .Revision }} + # paths: + # # This is a broad list of cache paths to include many possible development environments + # # You can probably delete some of these entries + # - ~/.m2 + # - ~/.ivy2 + # - ~/.sbt + # - ~/.bundle + # - ~/.go_workspace + # - ~/.gradle + # - ".git" + # - ~/.stack + # - ~/R + ## save "default" cache using the key "source-v2-" + #- save_cache: + # key: source-v2- + # paths: + # # This is a broad list of cache paths to include many possible development environments + # # You can probably delete some of these entries + # - vendor/bundle + # - ~/.m2 + # - ~/.ivy2 + # - ~/.sbt + # - ~/.bundle + # - ~/.go_workspace + # - ~/.gradle + # - ~/.cache/bower + # - ".git" + # - ~/.stack + # - ~/R # Teardown # If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each # Save test results diff --git a/CI/circle_parallel.sh b/CI/circle_parallel.sh index b5baa82c9604..8b6a40983aa5 100755 --- a/CI/circle_parallel.sh +++ b/CI/circle_parallel.sh @@ -10,10 +10,13 @@ set -e export NODE_ENV=test if [ "$NODE_INDEX" = "1" ]; then - echo "Running node $NODE_INDEX to test 'samples.circleci' defined in pom.xml ..." + echo "Running node $NODE_INDEX ..." java -version - ./mvnw --no-snapshot-updates --quiet verify -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error + (cd samples/client/petstore/ruby && mvn integration-test) + (cd samples/client/petstore/ruby-faraday && mvn integration-test) + (cd samples/client/petstore/ruby-httpx && mvn integration-test) + (cd samples/client/petstore/ruby-autoload && mvn integration-test) elif [ "$NODE_INDEX" = "2" ]; then echo "Running node $NODE_INDEX to test Go" @@ -33,20 +36,14 @@ elif [ "$NODE_INDEX" = "2" ]; then export PATH="/usr/local/go1.18/go/bin:$PATH" go version - # run integration tests - ./mvnw --no-snapshot-updates --quiet verify -Psamples.misc -Dorg.slf4j.simpleLogger.defaultLogLevel=error + # run go integration tests + (cd samples/client/petstore/go && mvn integration-test) + (cd samples/openapi3/client/petstore/go && mvn integration-test) + (cd samples/openapi3/client/petstore/go-petstore-generateMarshalJSON-false && mvn integration-test) + elif [ "$NODE_INDEX" = "3" ]; then - echo "Running node $NODE_INDEX to test 'samples.circleci.node3' defined in pom.xml ..." - #wget https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tgz - #tar -xf Python-3.8.9.tgz - #cd Python-3.8.9 - #./configure --enable-optimizations - #sudo make altinstall - pyenv install --list - pyenv install 3.7.12 - #pyenv install 2.7.14 #python2 no longer supported - pyenv global 3.7.12 + echo "Running node $NODE_INDEX ... " # Install node@stable (for angular 6) set +e @@ -63,23 +60,71 @@ elif [ "$NODE_INDEX" = "3" ]; then echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV - ./mvnw --no-snapshot-updates --quiet verify -Psamples.circleci.node3 -Dorg.slf4j.simpleLogger.defaultLogLevel=error + (cd samples/client/others/typescript-angular && mvn integration-test) + (cd samples/client/petstore/typescript-angular-v12-provided-in-root && mvn integration-test) + (cd samples/client/petstore/typescript-angular-v13-provided-in-root && mvn integration-test) + (cd samples/client/petstore/typescript-angular-v14-provided-in-root && mvn integration-test) + (cd samples/client/petstore/typescript-angular-v15-provided-in-root && mvn integration-test) + (cd samples/client/petstore/typescript-angular-v16-provided-in-root && mvn integration-test) + (cd samples/openapi3/client/petstore/typescript/builds/default && mvn integration-test) + (cd samples/openapi3/client/petstore/typescript/tests/default && mvn integration-test) + (cd samples/openapi3/client/petstore/typescript/builds/jquery && mvn integration-test) + (cd samples/openapi3/client/petstore/typescript/tests/jquery && mvn integration-test) + (cd samples/openapi3/client/petstore/typescript/builds/object_params && mvn integration-test) + (cd samples/openapi3/client/petstore/typescript/tests/object_params && mvn integration-test) + (cd samples/openapi3/client/petstore/typescript/builds/inversify && mvn integration-test) + (cd samples/openapi3/client/petstore/typescript/tests/inversify && mvn integration-test) + #(cd samples/openapi3/client/petstore/typescript/tests/deno && mvn integration-test) + (cd samples/openapi3/client/petstore/typescript/builds/browser && mvn integration-test) + (cd samples/openapi3/client/petstore/typescript/tests/browser && mvn integration-test) + (cd samples/client/petstore/typescript-fetch/builds/default && mvn integration-test) + (cd samples/client/petstore/typescript-fetch/builds/es6-target && mvn integration-test) + (cd samples/client/petstore/typescript-fetch/builds/with-npm-version && mvn integration-test) + (cd samples/client/petstore/typescript-fetch/tests/default && mvn integration-test) + (cd samples/client/petstore/typescript-node/npm && mvn integration-test) + (cd samples/client/petstore/typescript-rxjs/builds/with-npm-version && mvn integration-test) + (cd samples/client/petstore/typescript-axios/builds/with-npm-version && mvn integration-test) + (cd samples/client/petstore/typescript-axios/tests/default && mvn integration-test) + (cd samples/client/petstore/javascript-flowtyped && mvn integration-test) + (cd samples/client/petstore/javascript-es6 && mvn integration-test) + (cd samples/client/petstore/javascript-promise-es6 && mvn integration-test) elif [ "$NODE_INDEX" = "4" ]; then - echo "Running node $NODE_INDEX to test 'samples.circleci.node4' defined in pom.xml ..." + echo "Running node $NODE_INDEX ..." - #mvn --no-snapshot-updates --quiet verify -Psamples.circleci.node4 -Dorg.slf4j.simpleLogger.defaultLogLevel=error - #(cd samples/openapi3/client/petstore/python && make test) - # comment out due to ModuleNotFoundError: No module named 'urllib3.request' - #(cd samples/openapi3/client/petstore/python-prior && make test) - #(cd samples/openapi3/client/3_0_3_unit_test/python && make test) + #wget https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tgz + #tar -xf Python-3.8.9.tgz + #cd Python-3.8.9 + #./configure --enable-optimizations + #sudo make altinstall + pyenv install --list + pyenv install 3.7.12 + #pyenv install 2.7.14 #python2 no longer supported + pyenv global 3.7.12 + + (cd samples/openapi3/client/petstore/python && mvn integration-test) + (cd samples/openapi3/client/petstore/python-pydantic-v1 && mvn integration-test) + (cd samples/openapi3/client/petstore/python-aiohttp && mvn integration-test) + (cd samples/openapi3/client/petstore/python-pydantic-v1-aiohttp && mvn integration-test) else - echo "Running node $NODE_INDEX to test 'samples.circleci.others' defined in pom.xml ..." + echo "Running node $NODE_INDEX ..." java -version - ./mvnw --no-snapshot-updates --quiet verify -Psamples.circleci.others -Dorg.slf4j.simpleLogger.defaultLogLevel=error - ./mvnw --no-snapshot-updates --quiet javadoc:javadoc -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error + (cd samples/client/petstore/scala-akka && mvn integration-test) + (cd samples/client/petstore/scala-sttp && mvn integration-test) + (cd samples/client/petstore/scala-sttp4 && mvn integration-test) + (cd samples/client/petstore/clojure && mvn integration-test) + (cd samples/client/petstore/java/jersey2-java8 && mvn integration-test) + (cd samples/openapi3/client/petstore/java/jersey2-java8 && mvn integration-test) + (cd samples/client/petstore/java/jersey3 && mvn integration-test) + (cd samples/client/others/java/okhttp-gson-streaming && mvn integration-test) + (cd samples/client/petstore/java/okhttp-gson && mvn integration-test) + (cd samples/client/petstore/java/okhttp-gson-3.1 && mvn integration-test) + (cd samples/client/petstore/java/resteasy && mvn integration-test) + (cd samples/client/petstore/java-micronaut-client && mvn integration-test) + (cd samples/client/petstore/java/apache-httpclient && mvn integration-test) + fi diff --git a/pom.xml b/pom.xml index 8ba0b3f21115..12b870bd5e52 100644 --- a/pom.xml +++ b/pom.xml @@ -1119,245 +1119,6 @@ samples/server/petstore/java-undertow - - samples - - - env - samples - - - - - - - - - - - - - samples/client/petstore/rust - samples/client/petstore/rust/hyper/petstore - samples/client/petstore/rust/reqwest/petstore - samples/client/petstore/rust/reqwest/petstore-async - samples/client/petstore/rust/reqwest/petstore-async-middleware - - - - - - samples.circleci - - - env - samples.circleci - - - - samples/client/petstore/ruby - samples/client/petstore/ruby-faraday - samples/client/petstore/ruby-httpx - samples/client/petstore/ruby-autoload - - - - samples.circleci.spring - - - env - samples.circleci.spring - - - - - samples/client/petstore/spring-cloud - - - - - samples.circleci.node3 - - - env - samples.circleci.node3 - - - - - samples/openapi3/client/petstore/python - samples/openapi3/client/petstore/python-pydantic-v1 - samples/openapi3/client/petstore/python-aiohttp - samples/openapi3/client/petstore/python-pydantic-v1-aiohttp - - - samples/client/others/typescript-angular - samples/client/petstore/typescript-angular-v12-provided-in-root - samples/client/petstore/typescript-angular-v13-provided-in-root - samples/client/petstore/typescript-angular-v14-provided-in-root - samples/client/petstore/typescript-angular-v15-provided-in-root - samples/client/petstore/typescript-angular-v16-provided-in-root - samples/openapi3/client/petstore/typescript/builds/default - samples/openapi3/client/petstore/typescript/tests/default - samples/openapi3/client/petstore/typescript/builds/jquery - samples/openapi3/client/petstore/typescript/tests/jquery - samples/openapi3/client/petstore/typescript/builds/object_params - samples/openapi3/client/petstore/typescript/tests/object_params - samples/openapi3/client/petstore/typescript/builds/inversify - - samples/openapi3/client/petstore/typescript/builds/browser - samples/openapi3/client/petstore/typescript/tests/browser - samples/client/petstore/typescript-fetch/builds/default - samples/client/petstore/typescript-fetch/builds/es6-target - samples/client/petstore/typescript-fetch/builds/with-npm-version - samples/client/petstore/typescript-fetch/tests/default - samples/client/petstore/typescript-node/npm - samples/client/petstore/typescript-rxjs/builds/with-npm-version - samples/client/petstore/typescript-axios/builds/with-npm-version - samples/client/petstore/typescript-axios/tests/default - samples/client/petstore/javascript-flowtyped - samples/client/petstore/javascript-es6 - samples/client/petstore/javascript-promise-es6 - - - - - samples.circleci.node4 - - - env - samples.circleci.node4 - - - - - - - - samples.circleci.others - - - env - samples.circleci.others - - - - - - samples/client/petstore/scala-akka - samples/client/petstore/scala-sttp - samples/client/petstore/scala-sttp4 - samples/client/petstore/clojure - samples/client/petstore/java/jersey2-java8 - samples/openapi3/client/petstore/java/jersey2-java8 - samples/client/petstore/java/jersey3 - samples/client/others/java/okhttp-gson-streaming - samples/client/petstore/java/okhttp-gson - samples/client/petstore/java/okhttp-gson-3.1 - samples/client/petstore/java/resteasy - samples/client/petstore/java-micronaut-client - samples/client/petstore/java/apache-httpclient - - samples/server/petstore/java-undertow - - - - - samples.misc - - - env - samples.misc - - - - - - - - - samples/client/petstore/go - samples/openapi3/client/petstore/go - samples/openapi3/client/petstore/go-petstore-generateMarshalJSON-false - - - - - samples.dart - - - env - samples.dart - - - - samples/openapi3/client/petstore/dart2/petstore_client_lib - samples/openapi3/client/petstore/dart-dio/oneof - samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance - samples/openapi3/client/petstore/dart-dio/oneof_primitive - samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake - samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable - - - - samples.ios - - - env - samples.ios - - - - - samples/client/petstore/swift5/alamofireLibrary - samples/client/petstore/swift5/combineLibrary - samples/client/petstore/swift5/default - samples/client/petstore/swift5/deprecated - samples/client/petstore/swift5/frozenEnums - samples/client/petstore/swift5/nonPublicApi - samples/client/petstore/swift5/objcCompatible - samples/client/petstore/swift5/promisekitLibrary - samples/client/petstore/swift5/readonlyProperties - samples/client/petstore/swift5/resultLibrary - samples/client/petstore/swift5/rxswiftLibrary - samples/client/petstore/swift5/urlsessionLibrary - - - - - - openapi-generator From 2f655f1a9cec1f69bcd3487ea67d0d137dd7ac8d Mon Sep 17 00:00:00 2001 From: Ian Cubbon Date: Sun, 12 Nov 2023 19:01:32 -0700 Subject: [PATCH 12/12] Time parameters in the path resulted in code that would not compile (#17021) This is probably a pretty rare case as it just seems weird to have a time path parameter, but it's good to fix. --- .../go-server/controller-api.mustache | 4 +++- .../resources/3_0/go-server/petstore.yaml | 20 ++++++++++++++++ .../petstore/go-api-server/api/openapi.yaml | 22 ++++++++++++++++++ .../server/petstore/go-api-server/go/api.go | 2 ++ .../petstore/go-api-server/go/api_pet.go | 23 +++++++++++++++++++ .../go-api-server/go/api_pet_service.go | 11 +++++++++ .../petstore/go-chi-server/api/openapi.yaml | 22 ++++++++++++++++++ .../server/petstore/go-chi-server/go/api.go | 2 ++ .../petstore/go-chi-server/go/api_pet.go | 22 ++++++++++++++++++ .../go-chi-server/go/api_pet_service.go | 11 +++++++++ 10 files changed, 138 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache b/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache index 2ebd85e56fd0..30e4cfba7cba 100644 --- a/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache +++ b/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache @@ -169,7 +169,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re } {{/isInteger}} {{#isDateTime}} - {{paramName}}Param, err := time.Parse(time.RFC3339, {{#routers}}{{#mux}}params["{{baseName}}"]{{/mux}}{{#chi}}chi.URLParam(r, "{{baseName}}"){{/chi}}{{/routers}}) + {{paramName}}Param, err := parseTime({{#routers}}{{#mux}}params["{{baseName}}"]{{/mux}}{{#chi}}chi.URLParam(r, "{{baseName}}"){{/chi}}{{/routers}}) if err != nil { c.errorHandler(w, r, &ParsingError{Err: err}, nil) return @@ -180,6 +180,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re {{^isDouble}} {{^isLong}} {{^isInteger}} + {{^isDateTime}} {{^isEnumOrRef}} {{paramName}}Param := {{#routers}}{{#mux}}params["{{baseName}}"]{{/mux}}{{#chi}}chi.URLParam(r, "{{baseName}}"){{/chi}}{{/routers}} {{/isEnumOrRef}} @@ -190,6 +191,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re return } {{/isEnumOrRef}} + {{/isDateTime}} {{/isInteger}} {{/isLong}} {{/isDouble}} diff --git a/modules/openapi-generator/src/test/resources/3_0/go-server/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/go-server/petstore.yaml index 8756d176f8c1..90dca1b2166f 100644 --- a/modules/openapi-generator/src/test/resources/3_0/go-server/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/go-server/petstore.yaml @@ -745,6 +745,26 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiResponse' + /pets/byTime/{createdTime}: + get: + tags: + - pet + summary: Get the pets by time + operationId: GetPetsByTime + parameters: + - in: path + name: createdTime + required: true + schema: + type: string + format: date-time + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' externalDocs: description: Find out more about Swagger url: 'http://swagger.io' diff --git a/samples/server/petstore/go-api-server/api/openapi.yaml b/samples/server/petstore/go-api-server/api/openapi.yaml index ee7a4f70c132..3afede1048dc 100644 --- a/samples/server/petstore/go-api-server/api/openapi.yaml +++ b/samples/server/petstore/go-api-server/api/openapi.yaml @@ -761,6 +761,28 @@ paths: summary: Get the pets by only using boolean query parameters tags: - pet + /pets/byTime/{createdTime}: + get: + operationId: GetPetsByTime + parameters: + - explode: false + in: path + name: createdTime + required: true + schema: + format: date-time + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + summary: Get the pets by time + tags: + - pet components: requestBodies: UserArray: diff --git a/samples/server/petstore/go-api-server/go/api.go b/samples/server/petstore/go-api-server/go/api.go index 7af3533d1b80..2dab3b169782 100644 --- a/samples/server/petstore/go-api-server/go/api.go +++ b/samples/server/petstore/go-api-server/go/api.go @@ -30,6 +30,7 @@ type PetAPIRouter interface { FindPetsByTags(http.ResponseWriter, *http.Request) GetPetById(http.ResponseWriter, *http.Request) GetPetImageById(http.ResponseWriter, *http.Request) + GetPetsByTime(http.ResponseWriter, *http.Request) GetPetsUsingBooleanQueryParameters(http.ResponseWriter, *http.Request) UpdatePet(http.ResponseWriter, *http.Request) UpdatePetWithForm(http.ResponseWriter, *http.Request) @@ -73,6 +74,7 @@ type PetAPIServicer interface { FindPetsByTags(context.Context, []string, time.Time, time.Time) (ImplResponse, error) GetPetById(context.Context, int64) (ImplResponse, error) GetPetImageById(context.Context, int64) (ImplResponse, error) + GetPetsByTime(context.Context, time.Time) (ImplResponse, error) GetPetsUsingBooleanQueryParameters(context.Context, bool, bool, bool) (ImplResponse, error) UpdatePet(context.Context, Pet) (ImplResponse, error) UpdatePetWithForm(context.Context, int64, string, string) (ImplResponse, error) diff --git a/samples/server/petstore/go-api-server/go/api_pet.go b/samples/server/petstore/go-api-server/go/api_pet.go index c40f9c8fa927..68780fcff4bc 100644 --- a/samples/server/petstore/go-api-server/go/api_pet.go +++ b/samples/server/petstore/go-api-server/go/api_pet.go @@ -85,6 +85,11 @@ func (c *PetAPIController) Routes() Routes { "/v2/pet/{petId}/uploadImage", c.GetPetImageById, }, + "GetPetsByTime": Route{ + strings.ToUpper("Get"), + "/v2/pets/byTime/{createdTime}", + c.GetPetsByTime, + }, "GetPetsUsingBooleanQueryParameters": Route{ strings.ToUpper("Get"), "/v2/pets/boolean/parsing", @@ -294,6 +299,24 @@ func (c *PetAPIController) GetPetImageById(w http.ResponseWriter, r *http.Reques EncodeJSONResponse(result.Body, &result.Code, result.Headers, w) } +// GetPetsByTime - Get the pets by time +func (c *PetAPIController) GetPetsByTime(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + createdTimeParam, err := parseTime(params["createdTime"]) + if err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + result, err := c.service.GetPetsByTime(r.Context(), createdTimeParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, result.Headers, w) +} + // GetPetsUsingBooleanQueryParameters - Get the pets by only using boolean query parameters func (c *PetAPIController) GetPetsUsingBooleanQueryParameters(w http.ResponseWriter, r *http.Request) { query := r.URL.Query() diff --git a/samples/server/petstore/go-api-server/go/api_pet_service.go b/samples/server/petstore/go-api-server/go/api_pet_service.go index c8cb1a207160..a63455b2ba4c 100644 --- a/samples/server/petstore/go-api-server/go/api_pet_service.go +++ b/samples/server/petstore/go-api-server/go/api_pet_service.go @@ -130,6 +130,17 @@ func (s *PetAPIService) GetPetImageById(ctx context.Context, petId int64) (ImplR return Response(http.StatusNotImplemented, nil), errors.New("GetPetImageById method not implemented") } +// GetPetsByTime - Get the pets by time +func (s *PetAPIService) GetPetsByTime(ctx context.Context, createdTime time.Time) (ImplResponse, error) { + // TODO - update GetPetsByTime with the required logic for this service method. + // Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, ApiResponse{}) or use other options such as http.Ok ... + // return Response(200, ApiResponse{}), nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetPetsByTime method not implemented") +} + // GetPetsUsingBooleanQueryParameters - Get the pets by only using boolean query parameters func (s *PetAPIService) GetPetsUsingBooleanQueryParameters(ctx context.Context, expr bool, grouping bool, inactive bool) (ImplResponse, error) { // TODO - update GetPetsUsingBooleanQueryParameters with the required logic for this service method. diff --git a/samples/server/petstore/go-chi-server/api/openapi.yaml b/samples/server/petstore/go-chi-server/api/openapi.yaml index ee7a4f70c132..3afede1048dc 100644 --- a/samples/server/petstore/go-chi-server/api/openapi.yaml +++ b/samples/server/petstore/go-chi-server/api/openapi.yaml @@ -761,6 +761,28 @@ paths: summary: Get the pets by only using boolean query parameters tags: - pet + /pets/byTime/{createdTime}: + get: + operationId: GetPetsByTime + parameters: + - explode: false + in: path + name: createdTime + required: true + schema: + format: date-time + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + description: successful operation + summary: Get the pets by time + tags: + - pet components: requestBodies: UserArray: diff --git a/samples/server/petstore/go-chi-server/go/api.go b/samples/server/petstore/go-chi-server/go/api.go index 7af3533d1b80..2dab3b169782 100644 --- a/samples/server/petstore/go-chi-server/go/api.go +++ b/samples/server/petstore/go-chi-server/go/api.go @@ -30,6 +30,7 @@ type PetAPIRouter interface { FindPetsByTags(http.ResponseWriter, *http.Request) GetPetById(http.ResponseWriter, *http.Request) GetPetImageById(http.ResponseWriter, *http.Request) + GetPetsByTime(http.ResponseWriter, *http.Request) GetPetsUsingBooleanQueryParameters(http.ResponseWriter, *http.Request) UpdatePet(http.ResponseWriter, *http.Request) UpdatePetWithForm(http.ResponseWriter, *http.Request) @@ -73,6 +74,7 @@ type PetAPIServicer interface { FindPetsByTags(context.Context, []string, time.Time, time.Time) (ImplResponse, error) GetPetById(context.Context, int64) (ImplResponse, error) GetPetImageById(context.Context, int64) (ImplResponse, error) + GetPetsByTime(context.Context, time.Time) (ImplResponse, error) GetPetsUsingBooleanQueryParameters(context.Context, bool, bool, bool) (ImplResponse, error) UpdatePet(context.Context, Pet) (ImplResponse, error) UpdatePetWithForm(context.Context, int64, string, string) (ImplResponse, error) diff --git a/samples/server/petstore/go-chi-server/go/api_pet.go b/samples/server/petstore/go-chi-server/go/api_pet.go index 4b22302e1ed7..68d5bbcd057e 100644 --- a/samples/server/petstore/go-chi-server/go/api_pet.go +++ b/samples/server/petstore/go-chi-server/go/api_pet.go @@ -85,6 +85,11 @@ func (c *PetAPIController) Routes() Routes { "/v2/pet/{petId}/uploadImage", c.GetPetImageById, }, + "GetPetsByTime": Route{ + strings.ToUpper("Get"), + "/v2/pets/byTime/{createdTime}", + c.GetPetsByTime, + }, "GetPetsUsingBooleanQueryParameters": Route{ strings.ToUpper("Get"), "/v2/pets/boolean/parsing", @@ -290,6 +295,23 @@ func (c *PetAPIController) GetPetImageById(w http.ResponseWriter, r *http.Reques EncodeJSONResponse(result.Body, &result.Code, result.Headers, w) } +// GetPetsByTime - Get the pets by time +func (c *PetAPIController) GetPetsByTime(w http.ResponseWriter, r *http.Request) { + createdTimeParam, err := parseTime(chi.URLParam(r, "createdTime")) + if err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + result, err := c.service.GetPetsByTime(r.Context(), createdTimeParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, result.Headers, w) +} + // GetPetsUsingBooleanQueryParameters - Get the pets by only using boolean query parameters func (c *PetAPIController) GetPetsUsingBooleanQueryParameters(w http.ResponseWriter, r *http.Request) { query := r.URL.Query() diff --git a/samples/server/petstore/go-chi-server/go/api_pet_service.go b/samples/server/petstore/go-chi-server/go/api_pet_service.go index c8cb1a207160..a63455b2ba4c 100644 --- a/samples/server/petstore/go-chi-server/go/api_pet_service.go +++ b/samples/server/petstore/go-chi-server/go/api_pet_service.go @@ -130,6 +130,17 @@ func (s *PetAPIService) GetPetImageById(ctx context.Context, petId int64) (ImplR return Response(http.StatusNotImplemented, nil), errors.New("GetPetImageById method not implemented") } +// GetPetsByTime - Get the pets by time +func (s *PetAPIService) GetPetsByTime(ctx context.Context, createdTime time.Time) (ImplResponse, error) { + // TODO - update GetPetsByTime with the required logic for this service method. + // Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation. + + // TODO: Uncomment the next line to return response Response(200, ApiResponse{}) or use other options such as http.Ok ... + // return Response(200, ApiResponse{}), nil + + return Response(http.StatusNotImplemented, nil), errors.New("GetPetsByTime method not implemented") +} + // GetPetsUsingBooleanQueryParameters - Get the pets by only using boolean query parameters func (s *PetAPIService) GetPetsUsingBooleanQueryParameters(ctx context.Context, expr bool, grouping bool, inactive bool) (ImplResponse, error) { // TODO - update GetPetsUsingBooleanQueryParameters with the required logic for this service method.