mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
Replace powershell generator with powershell-experimental generator (#6213)
* replace powershell generator with powershell-experimental generator * add back samples * add back scripts * remove outdated script * update doc
This commit is contained in:
parent
6e619e0a15
commit
f327f01c19
@ -70,7 +70,7 @@ test_script:
|
||||
# test ps pestore
|
||||
- ps: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
cd samples\client\petstore\powershell-experimental\
|
||||
cd samples\client\petstore\powershell\
|
||||
.\Build.ps1
|
||||
Import-Module -Name '.\src\PSPetstore'
|
||||
$Result = Invoke-Pester -PassThru
|
||||
|
@ -1,32 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=$(ls -ld "$SCRIPT")
|
||||
link=$(expr "$ls" : '.*-> \(.*\)$')
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=$(dirname "$SCRIPT")/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=$(dirname "$SCRIPT")/..
|
||||
APP_DIR=$(cd "${APP_DIR}"; pwd)
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/powershell-experimental -i modules/openapi-generator/src/test/resources/3_0/powershell/petstore.yaml -g powershell-experimental -o samples/client/petstore/powershell-experimental --additional-properties powershellGalleryUrl=https://www.powershellgallery.com/packages/PSPetstore,packageGuid=a27b908d-2a20-467f-bc32-af6f3a654ac5,packageName=PSPetstore,apiNamePrefix=PS,packageVersion=0.1.2,commonVerbs=Delete=Remove:Patch=Update $@"
|
||||
|
||||
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
@ -1,32 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/powershell -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g powershell -o samples/client/petstore/powershell --additional-properties packageGuid=a27b908d-2a20-467f-bc32-af6f3a654ac5,csharpClientPath=\$ScriptDir\..\..\petstore\csharp\OpenAPIClient $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/powershell -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g powershell -o samples/client/petstore/powershell --additional-properties packageGuid=a27b908d-2a20-467f-bc32-af6f3a654ac5,csharpClientPath=\$ScriptDir\..\..\petstore\csharp\OpenAPIClient $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/powershell -i modules/openapi-generator/src/test/resources/3_0/powershell/petstore.yaml -g powershell -o samples/client/petstore/powershell --additional-properties powershellGalleryUrl=https://www.powershellgallery.com/packages/PSPetstore,packageGuid=a27b908d-2a20-467f-bc32-af6f3a654ac5,packageName=PSPetstore,apiNamePrefix=PS,packageVersion=0.1.2,commonVerbs=Delete=Remove:Patch=Update $@"
|
||||
|
||||
java ${JAVA_OPTS} -jar ${executable} ${ags}
|
||||
|
@ -1,10 +0,0 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g powershell -o samples\client\petstore\powershell --additional-properties packageGuid=a27b908d-2a20-467f-bc32-af6f3a654ac5,csharpClientPath=$ScriptDir\..\..\petstore\csharp\OpenAPIClient
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
10
bin/windows/powershell-petstore.bat
Executable file
10
bin/windows/powershell-petstore.bat
Executable file
@ -0,0 +1,10 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g powershell -o samples\client\petstorep\powershell --additional-properties powershellGalleryUrl=https://www.powershellgallery.com/packages/PSPetstore,packageGuid=a27b908d-2a20-467f-bc32-af6f3a654ac5,packageName=PSPetstore,apiNamePrefix=PS,packageVersion=0.1.2,commonVerbs=Delete=Remove:Patch=Update
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -46,8 +46,7 @@ The following generators are available:
|
||||
* [ocaml](generators/ocaml.md)
|
||||
* [perl](generators/perl.md)
|
||||
* [php](generators/php.md)
|
||||
* [powershell](generators/powershell.md)
|
||||
* [powershell-experimental (beta)](generators/powershell-experimental.md)
|
||||
* [powershell (beta)](generators/powershell.md)
|
||||
* [python](generators/python.md)
|
||||
* [python-experimental (experimental)](generators/python-experimental.md)
|
||||
* [r](generators/r.md)
|
||||
|
@ -5,9 +5,12 @@ sidebar_label: powershell
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|csharpClientPath|Path to the C# API client generated by OpenAPI Generator, e.g. $ScriptDir\..\csharp\OpenAPIClient where $ScriptDir is the current directory. NOTE: you will need to generate the C# API client separately.| |$ScriptDir\csharp\OpenAPIClient|
|
||||
|apiNamePrefix|Prefix that will be appended to all PS objects. Default: empty string. e.g. Pet => PSPet.| |null|
|
||||
|commonVerbs|PS common verb mappings. e.g. Delete=Remove:Patch=Update to map Delete with Remove and Patch with Update accordingly.| |null|
|
||||
|packageGuid|GUID for PowerShell module (e.g. a27b908d-2a20-467f-bc32-af6f3a654ac5). A random GUID will be generated by default.| |null|
|
||||
|packageName|Client package name (e.g. org.openapitools.client).| |Org.OpenAPITools|
|
||||
|packageName|Client package name (e.g. PSTwitter).| |PSOpenAPITools|
|
||||
|packageVersion|Package version (e.g. 0.1.2).| |0.1.2|
|
||||
|powershellGalleryUrl|URL to the module in PowerShell Gallery (e.g. https://www.powershellgallery.com/packages/PSTwitter/).| |null|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
@ -56,6 +59,7 @@ sidebar_label: powershell
|
||||
<li>Single</li>
|
||||
<li>String</li>
|
||||
<li>System.DateTime</li>
|
||||
<li>System.IO.FileInfo</li>
|
||||
<li>TimeSpan</li>
|
||||
<li>UInt16</li>
|
||||
<li>UInt32</li>
|
||||
@ -68,37 +72,70 @@ sidebar_label: powershell
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>Begin</li>
|
||||
<li>Break</li>
|
||||
<li>Catch</li>
|
||||
<li>Continue</li>
|
||||
<li>Data</li>
|
||||
<li>Do</li>
|
||||
<li>Dynamicparam</li>
|
||||
<li>Else</li>
|
||||
<li>Elseif</li>
|
||||
<li>End</li>
|
||||
<li>Exit</li>
|
||||
<li>Filter</li>
|
||||
<li>Finally</li>
|
||||
<li>For</li>
|
||||
<li>Foreach</li>
|
||||
<li>From</li>
|
||||
<li>Function</li>
|
||||
<li>If</li>
|
||||
<li>In</li>
|
||||
<li>Local</li>
|
||||
<li>Param</li>
|
||||
<li>Private</li>
|
||||
<li>Process</li>
|
||||
<li>Return</li>
|
||||
<li>Switch</li>
|
||||
<li>Throw</li>
|
||||
<li>Trap</li>
|
||||
<li>Try</li>
|
||||
<li>Until</li>
|
||||
<li>Where</li>
|
||||
<li>While</li>
|
||||
<li>args</li>
|
||||
<li>begin</li>
|
||||
<li>break</li>
|
||||
<li>catch</li>
|
||||
<li>consolefilename</li>
|
||||
<li>continue</li>
|
||||
<li>data</li>
|
||||
<li>do</li>
|
||||
<li>dynamicparam</li>
|
||||
<li>else</li>
|
||||
<li>elseif</li>
|
||||
<li>end</li>
|
||||
<li>error</li>
|
||||
<li>event</li>
|
||||
<li>eventargs</li>
|
||||
<li>eventsubscriber</li>
|
||||
<li>executioncontext</li>
|
||||
<li>exit</li>
|
||||
<li>false</li>
|
||||
<li>filter</li>
|
||||
<li>finally</li>
|
||||
<li>for</li>
|
||||
<li>foreach</li>
|
||||
<li>from</li>
|
||||
<li>function</li>
|
||||
<li>home</li>
|
||||
<li>host</li>
|
||||
<li>if</li>
|
||||
<li>in</li>
|
||||
<li>input</li>
|
||||
<li>lastexitcode</li>
|
||||
<li>local</li>
|
||||
<li>matches</li>
|
||||
<li>myinvocation</li>
|
||||
<li>nestedpromptlevel</li>
|
||||
<li>null</li>
|
||||
<li>param</li>
|
||||
<li>pid</li>
|
||||
<li>private</li>
|
||||
<li>process</li>
|
||||
<li>profile</li>
|
||||
<li>pscmdlet</li>
|
||||
<li>pscommandpath</li>
|
||||
<li>psculture</li>
|
||||
<li>psdebugcontext</li>
|
||||
<li>pshome</li>
|
||||
<li>psitem</li>
|
||||
<li>psscriptroot</li>
|
||||
<li>pssenderinfo</li>
|
||||
<li>psuiculture</li>
|
||||
<li>psversiontable</li>
|
||||
<li>return</li>
|
||||
<li>sender</li>
|
||||
<li>shellid</li>
|
||||
<li>stacktrace</li>
|
||||
<li>switch</li>
|
||||
<li>this</li>
|
||||
<li>throw</li>
|
||||
<li>trap</li>
|
||||
<li>true</li>
|
||||
<li>try</li>
|
||||
<li>until</li>
|
||||
<li>where</li>
|
||||
<li>while</li>
|
||||
</ul>
|
||||
|
||||
## FEATURE SET
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -19,8 +18,12 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
@ -39,10 +42,17 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
||||
|
||||
protected String sourceFolder = "src";
|
||||
protected String packageName = "Org.OpenAPITools";
|
||||
protected String csharpClientPath = "$ScriptDir\\csharp\\OpenAPIClient";
|
||||
protected String packageName = "PSOpenAPITools";
|
||||
protected String packageVersion = "0.1.2";
|
||||
protected String apiDocPath = "docs/";
|
||||
protected String modelDocPath = "docs/";
|
||||
protected String apiTestPath = "tests/Api";
|
||||
protected String modelTestPath = "tests/Model";
|
||||
protected HashSet nullablePrimitives;
|
||||
protected String powershellGalleryUrl;
|
||||
protected HashSet powershellVerbs;
|
||||
protected Map<String, String> commonVerbs; // verbs not in the official ps verb list but can be mapped to one of the verbs
|
||||
protected HashSet methodNames; // store a list of method names to detect duplicates
|
||||
|
||||
/**
|
||||
* Constructs an instance of `PowerShellClientCodegen`.
|
||||
@ -71,16 +81,20 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
ParameterFeature.Cookie
|
||||
)
|
||||
);
|
||||
|
||||
outputFolder = "generated-code" + File.separator + "powershell";
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.BETA)
|
||||
.build();
|
||||
|
||||
outputFolder = "generated-code" + File.separator + "powershell-expiermental";
|
||||
modelTemplateFiles.put("model.mustache", ".ps1");
|
||||
apiTemplateFiles.put("api.mustache", ".ps1");
|
||||
modelTestTemplateFiles.put("model_test.mustache", ".ps1");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".ps1");
|
||||
modelDocTemplateFiles.clear();
|
||||
apiDocTemplateFiles.clear();
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
embeddedTemplateDir = templateDir = "powershell";
|
||||
apiPackage = packageName + File.separator + "API";
|
||||
apiPackage = packageName + File.separator + "Api";
|
||||
modelPackage = packageName + File.separator + "Model";
|
||||
|
||||
// https://blogs.msdn.microsoft.com/powershell/2010/01/07/how-objects-are-sent-to-and-from-remote-sessions/
|
||||
@ -107,44 +121,329 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
"Boolean",
|
||||
"Guid",
|
||||
"Uri",
|
||||
"System.IO.FileInfo",
|
||||
"Version"
|
||||
));
|
||||
|
||||
// https://richardspowershellblog.wordpress.com/2009/05/02/powershell-reserved-words/
|
||||
reservedWords = new HashSet<String>(Arrays.asList(
|
||||
"Begin",
|
||||
"Break",
|
||||
"Catch",
|
||||
"Continue",
|
||||
"Data",
|
||||
"Do",
|
||||
"Dynamicparam",
|
||||
"Else",
|
||||
"Elseif",
|
||||
"End",
|
||||
commonVerbs = new HashMap<String, String>();
|
||||
|
||||
Map<String, List<String>> verbMappings = new HashMap<String, List<String>>();
|
||||
|
||||
// common
|
||||
verbMappings.put("Add", Arrays.asList("Append", "Attach", "Concatenate", "Insert"));
|
||||
verbMappings.put("Clear", Arrays.asList("Flush", "Erase", "Release", "Unmark", "Unset", "Nullify"));
|
||||
verbMappings.put("Close", Arrays.asList());
|
||||
verbMappings.put("Copy", Arrays.asList("Duplicate", "Clone", "Replicate", "Sync"));
|
||||
verbMappings.put("Enter", Arrays.asList("PushInto"));
|
||||
verbMappings.put("Exit", Arrays.asList("PopOut"));
|
||||
verbMappings.put("Find", Arrays.asList());
|
||||
verbMappings.put("Format", Arrays.asList());
|
||||
verbMappings.put("Get", Arrays.asList("Read", "Open", "Cat", "Type", "Dir", "Obtain", "Dump", "Acquire", "Examine", "Find", "Search"));
|
||||
verbMappings.put("Hide", Arrays.asList("Block"));
|
||||
verbMappings.put("Join", Arrays.asList("Combine", "Unite", "Connect", "Associate"));
|
||||
verbMappings.put("Lock", Arrays.asList("RestrictSecure"));
|
||||
verbMappings.put("Move", Arrays.asList("Transfer", "Name", "Migrate"));
|
||||
verbMappings.put("New", Arrays.asList("Create", "Generate", "Build", "Make", "Allocate"));
|
||||
verbMappings.put("Open", Arrays.asList());
|
||||
verbMappings.put("Optimize", Arrays.asList());
|
||||
verbMappings.put("Pop", Arrays.asList());
|
||||
verbMappings.put("Push", Arrays.asList());
|
||||
verbMappings.put("Redo", Arrays.asList());
|
||||
verbMappings.put("Remove", Arrays.asList("Clear", "Cut", "Dispose", "Discard", "Erase"));
|
||||
verbMappings.put("Rename", Arrays.asList("Change"));
|
||||
verbMappings.put("Reset", Arrays.asList());
|
||||
verbMappings.put("Search", Arrays.asList("FindLocate"));
|
||||
verbMappings.put("Select", Arrays.asList("FindLocate"));
|
||||
verbMappings.put("Set", Arrays.asList("Write", "Reset", "Assign", "Configure"));
|
||||
verbMappings.put("Show", Arrays.asList("DisplayProduce"));
|
||||
verbMappings.put("Skip", Arrays.asList("BypassJump"));
|
||||
verbMappings.put("Split", Arrays.asList("parate"));
|
||||
verbMappings.put("Step", Arrays.asList());
|
||||
verbMappings.put("Switch", Arrays.asList());
|
||||
verbMappings.put("Undo", Arrays.asList());
|
||||
verbMappings.put("Unlock", Arrays.asList("Release", "Unrestrict", "Unsecure"));
|
||||
verbMappings.put("Watch", Arrays.asList());
|
||||
|
||||
// communication
|
||||
verbMappings.put("Connect", Arrays.asList("JoinTelnet"));
|
||||
verbMappings.put("Disconnect", Arrays.asList("BreakLogoff"));
|
||||
verbMappings.put("Read", Arrays.asList("Acquire", "Prompt", "Get"));
|
||||
verbMappings.put("Receive", Arrays.asList("Read", "Accept", "Peek"));
|
||||
verbMappings.put("Send", Arrays.asList("Put", "Broadcast", "Mail", "Fax"));
|
||||
verbMappings.put("Write", Arrays.asList("PutPrint"));
|
||||
|
||||
// data
|
||||
verbMappings.put("Backup", Arrays.asList(" Save", " Burn", " Replicate", "Sync"));
|
||||
verbMappings.put("Checkpoint", Arrays.asList(" Diff"));
|
||||
verbMappings.put("Compare", Arrays.asList(" Diff"));
|
||||
verbMappings.put("Compress", Arrays.asList(" Compact"));
|
||||
verbMappings.put("Convert", Arrays.asList(" Change", " Resize", "Resample"));
|
||||
verbMappings.put("ConvertFrom", Arrays.asList(" Export", " Output", "Out"));
|
||||
verbMappings.put("ConvertTo", Arrays.asList(" Import", " Input", "In"));
|
||||
verbMappings.put("Dismount", Arrays.asList(" UnmountUnlink"));
|
||||
verbMappings.put("Edit", Arrays.asList(" Change", " Update", "Modify"));
|
||||
verbMappings.put("Expand", Arrays.asList(" ExplodeUncompress"));
|
||||
verbMappings.put("Export", Arrays.asList(" ExtractBackup"));
|
||||
verbMappings.put("Group", Arrays.asList(" Aggregate", " Arrange", " Associate", "Correlate"));
|
||||
verbMappings.put("Import", Arrays.asList(" BulkLoadLoad"));
|
||||
verbMappings.put("Initialize", Arrays.asList(" Erase", " Init", " Renew", " Rebuild", " Reinitialize", "Setup"));
|
||||
verbMappings.put("Limit", Arrays.asList(" Quota"));
|
||||
verbMappings.put("Merge", Arrays.asList(" CombineJoin"));
|
||||
verbMappings.put("Mount", Arrays.asList(" Connect"));
|
||||
verbMappings.put("Out", Arrays.asList());
|
||||
verbMappings.put("Publish", Arrays.asList(" Deploy", " Release", "Install"));
|
||||
verbMappings.put("Restore", Arrays.asList(" Repair", " Return", " Undo", "Fix"));
|
||||
verbMappings.put("Save", Arrays.asList());
|
||||
verbMappings.put("Sync", Arrays.asList(" Replicate", " Coerce", "Match"));
|
||||
verbMappings.put("Unpublish", Arrays.asList(" Uninstall", " Revert", "Hide"));
|
||||
verbMappings.put("Update", Arrays.asList(" Refresh", " Renew", " Recalculate", "Re-index"));
|
||||
|
||||
// diagnostic
|
||||
verbMappings.put("Debug", Arrays.asList("Diagnose"));
|
||||
verbMappings.put("Measure", Arrays.asList("Calculate", "Determine", "Analyze"));
|
||||
verbMappings.put("Ping", Arrays.asList());
|
||||
verbMappings.put("Repair", Arrays.asList("FixRestore"));
|
||||
verbMappings.put("Resolve", Arrays.asList("ExpandDetermine"));
|
||||
verbMappings.put("Test", Arrays.asList("Diagnose", "Analyze", "Salvage", "Verify"));
|
||||
verbMappings.put("Trace", Arrays.asList("Track", "Follow", "Inspect", "Dig"));
|
||||
|
||||
// lifecycle
|
||||
verbMappings.put("Approve", Arrays.asList());
|
||||
verbMappings.put("Assert", Arrays.asList("Certify"));
|
||||
verbMappings.put("Build", Arrays.asList());
|
||||
verbMappings.put("Complete", Arrays.asList());
|
||||
verbMappings.put("Confirm", Arrays.asList("Acknowledge", "Agree", "Certify", "Validate", "Verify"));
|
||||
verbMappings.put("Deny", Arrays.asList("Block", "Object", "Refuse", "Reject"));
|
||||
verbMappings.put("Deploy", Arrays.asList());
|
||||
verbMappings.put("Disable", Arrays.asList("HaltHide"));
|
||||
verbMappings.put("Enable", Arrays.asList("StartBegin"));
|
||||
verbMappings.put("Install", Arrays.asList("Setup"));
|
||||
verbMappings.put("Invoke", Arrays.asList("RunStart"));
|
||||
verbMappings.put("Register", Arrays.asList());
|
||||
verbMappings.put("Request", Arrays.asList());
|
||||
verbMappings.put("Restart", Arrays.asList("Recycle"));
|
||||
verbMappings.put("Resume", Arrays.asList());
|
||||
verbMappings.put("Start", Arrays.asList("Launch", "Initiate", "Boot"));
|
||||
verbMappings.put("Stop", Arrays.asList("End", "Kill", "Terminate", "Cancel"));
|
||||
verbMappings.put("Submit", Arrays.asList("Post"));
|
||||
verbMappings.put("Suspend", Arrays.asList("Pause"));
|
||||
verbMappings.put("Uninstall", Arrays.asList());
|
||||
verbMappings.put("Unregister", Arrays.asList("Remove"));
|
||||
verbMappings.put("Wait", Arrays.asList("SleepPause"));
|
||||
|
||||
// security
|
||||
verbMappings.put("Block", Arrays.asList("Prevent", "Limit", "Deny"));
|
||||
verbMappings.put("Grant", Arrays.asList("AllowEnable"));
|
||||
verbMappings.put("Protect", Arrays.asList("Encrypt", "Safeguard", "Seal"));
|
||||
verbMappings.put("Revoke", Arrays.asList("RemoveDisable"));
|
||||
verbMappings.put("Unblock", Arrays.asList("ClearAllow"));
|
||||
verbMappings.put("Unprotect", Arrays.asList("DecryptUnseal"));
|
||||
|
||||
// other
|
||||
verbMappings.put("Use", Arrays.asList());
|
||||
|
||||
for (Map.Entry<String, List<String>> entry : verbMappings.entrySet()) {
|
||||
// loop through each verb in the list
|
||||
for (String verb : entry.getValue()) {
|
||||
if (verbMappings.containsKey(verb)) {
|
||||
// the verb to be mapped is also a common verb, do nothing
|
||||
LOGGER.debug("verbmapping: skipped {}", verb);
|
||||
} else {
|
||||
commonVerbs.put(verb, entry.getKey());
|
||||
LOGGER.debug("verbmapping: adding {} => {}", verb, entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
powershellVerbs = new HashSet<String>(Arrays.asList(
|
||||
"Add",
|
||||
"Clear",
|
||||
"Close",
|
||||
"Copy",
|
||||
"Enter",
|
||||
"Exit",
|
||||
"Filter",
|
||||
"Finally",
|
||||
"For",
|
||||
"Foreach",
|
||||
"From",
|
||||
"Function",
|
||||
"If",
|
||||
"In",
|
||||
"Param",
|
||||
"Process",
|
||||
"Return",
|
||||
"Find",
|
||||
"Format",
|
||||
"Get",
|
||||
"Hide",
|
||||
"Join",
|
||||
"Lock",
|
||||
"Move",
|
||||
"New",
|
||||
"Open",
|
||||
"Optimize",
|
||||
"Pop",
|
||||
"Push",
|
||||
"Redo",
|
||||
"Remove",
|
||||
"Rename",
|
||||
"Reset",
|
||||
"Search",
|
||||
"Select",
|
||||
"Set",
|
||||
"Show",
|
||||
"Skip",
|
||||
"Split",
|
||||
"Step",
|
||||
"Switch",
|
||||
"Throw",
|
||||
"Trap",
|
||||
"Try",
|
||||
"Until",
|
||||
"While",
|
||||
"Local",
|
||||
"Private",
|
||||
"Where"
|
||||
"Undo",
|
||||
"Unlock",
|
||||
"Watch",
|
||||
"Connect",
|
||||
"Disconnect",
|
||||
"Read",
|
||||
"Receive",
|
||||
"Send",
|
||||
"Write",
|
||||
"Backup",
|
||||
"Checkpoint",
|
||||
"Compare",
|
||||
"Compress",
|
||||
"Convert",
|
||||
"ConvertFrom",
|
||||
"ConvertTo",
|
||||
"Dismount",
|
||||
"Edit",
|
||||
"Expand",
|
||||
"Export",
|
||||
"Group",
|
||||
"Import",
|
||||
"Initialize",
|
||||
"Limit",
|
||||
"Merge",
|
||||
"Mount",
|
||||
"Out",
|
||||
"Publish",
|
||||
"Restore",
|
||||
"Save",
|
||||
"Sync",
|
||||
"Unpublish",
|
||||
"Update",
|
||||
"Debug",
|
||||
"Measure",
|
||||
"Ping",
|
||||
"Repair",
|
||||
"Resolve",
|
||||
"Test",
|
||||
"Trace",
|
||||
"Approve",
|
||||
"Assert",
|
||||
"Build",
|
||||
"Complete",
|
||||
"Confirm",
|
||||
"Deny",
|
||||
"Deploy",
|
||||
"Disable",
|
||||
"Enable",
|
||||
"Install",
|
||||
"Invoke",
|
||||
"Register",
|
||||
"Request",
|
||||
"Restart",
|
||||
"Resume",
|
||||
"Start",
|
||||
"Stop",
|
||||
"Submit",
|
||||
"Suspend",
|
||||
"Uninstall",
|
||||
"Unregister",
|
||||
"Wait",
|
||||
"Block",
|
||||
"Grant",
|
||||
"Protect",
|
||||
"Revoke",
|
||||
"Unblock",
|
||||
"Unprotect",
|
||||
"Use"
|
||||
));
|
||||
|
||||
methodNames = new HashSet<String>();
|
||||
|
||||
nullablePrimitives = new HashSet<String>(Arrays.asList(
|
||||
"System.Nullable[Byte]",
|
||||
"System.Nullable[SByte]",
|
||||
"System.Nullable[Int16]",
|
||||
"System.Nullable[Int32]",
|
||||
"System.Nullable[Int64]",
|
||||
"System.Nullable[UInt16]",
|
||||
"System.Nullable[UInt32]",
|
||||
"System.Nullable[UInt64]",
|
||||
"System.Nullable[Decimal]",
|
||||
"System.Nullable[Single]",
|
||||
"System.Nullable[Double]",
|
||||
"System.Nullable[Boolean]"
|
||||
));
|
||||
|
||||
// list of reserved words - must be in lower case
|
||||
reservedWords = new HashSet<String>(Arrays.asList(
|
||||
// https://richardspowershellblog.wordpress.com/2009/05/02/powershell-reserved-words/
|
||||
"begin",
|
||||
"break",
|
||||
"catch",
|
||||
"continue",
|
||||
"data",
|
||||
"do",
|
||||
"dynamicparam",
|
||||
"else",
|
||||
"elseif",
|
||||
"end",
|
||||
"exit",
|
||||
"filter",
|
||||
"finally",
|
||||
"for",
|
||||
"foreach",
|
||||
"from",
|
||||
"function",
|
||||
"if",
|
||||
"in",
|
||||
"param",
|
||||
"process",
|
||||
"return",
|
||||
"switch",
|
||||
"throw",
|
||||
"trap",
|
||||
"try",
|
||||
"until",
|
||||
"while",
|
||||
"local",
|
||||
"private",
|
||||
"where",
|
||||
// special variables
|
||||
"args",
|
||||
"consolefilename",
|
||||
"error",
|
||||
"event",
|
||||
"eventargs",
|
||||
"eventsubscriber",
|
||||
"executioncontext",
|
||||
"false",
|
||||
"foreach",
|
||||
"home",
|
||||
"host",
|
||||
"input",
|
||||
"lastexitcode",
|
||||
"matches",
|
||||
"myinvocation",
|
||||
"nestedpromptlevel",
|
||||
"null",
|
||||
"pid",
|
||||
"profile",
|
||||
"pscmdlet",
|
||||
"pscommandpath",
|
||||
"psculture",
|
||||
"psdebugcontext",
|
||||
"pshome",
|
||||
"psitem",
|
||||
"psscriptroot",
|
||||
"pssenderinfo",
|
||||
"psuiculture",
|
||||
"psversiontable",
|
||||
"sender",
|
||||
"shellid",
|
||||
"stacktrace",
|
||||
"this",
|
||||
"true"
|
||||
));
|
||||
|
||||
defaultIncludes = new HashSet<String>(Arrays.asList(
|
||||
"Byte",
|
||||
@ -169,6 +468,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
"Boolean",
|
||||
"Guid",
|
||||
"Uri",
|
||||
"System.IO.FileInfo",
|
||||
"Version"
|
||||
));
|
||||
|
||||
@ -180,18 +480,24 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
typeMapping.put("long", "Int64");
|
||||
typeMapping.put("double", "Double");
|
||||
typeMapping.put("number", "Decimal");
|
||||
typeMapping.put("date-time", "System.DateTime");
|
||||
typeMapping.put("object", "System.Collections.Hashtable");
|
||||
typeMapping.put("file", "System.IO.FileInfo");
|
||||
typeMapping.put("ByteArray", "System.Byte[]");
|
||||
typeMapping.put("binary", "System.IO.FileInfo");
|
||||
typeMapping.put("date", "System.DateTime");
|
||||
typeMapping.put("file", "String");
|
||||
typeMapping.put("object", "String");
|
||||
typeMapping.put("binary", "String");
|
||||
typeMapping.put("date-time", "System.DateTime");
|
||||
typeMapping.put("Date", "System.DateTime");
|
||||
typeMapping.put("DateTime", "System.DateTime");
|
||||
typeMapping.put("UUID", "String");
|
||||
typeMapping.put("URI", "String");
|
||||
|
||||
cliOptions.clear();
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Client package name (e.g. org.openapitools.client).").defaultValue(this.packageName));
|
||||
cliOptions.add(new CliOption("powershellGalleryUrl", "URL to the module in PowerShell Gallery (e.g. https://www.powershellgallery.com/packages/PSTwitter/)."));
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Client package name (e.g. PSTwitter).").defaultValue(this.packageName));
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Package version (e.g. 0.1.2).").defaultValue(this.packageVersion));
|
||||
cliOptions.add(new CliOption(CodegenConstants.OPTIONAL_PROJECT_GUID, "GUID for PowerShell module (e.g. a27b908d-2a20-467f-bc32-af6f3a654ac5). A random GUID will be generated by default."));
|
||||
cliOptions.add(new CliOption("csharpClientPath", "Path to the C# API client generated by OpenAPI Generator, e.g. $ScriptDir\\..\\csharp\\OpenAPIClient where $ScriptDir is the current directory. NOTE: you will need to generate the C# API client separately.").defaultValue(this.csharpClientPath));
|
||||
cliOptions.add(new CliOption(CodegenConstants.API_NAME_PREFIX, "Prefix that will be appended to all PS objects. Default: empty string. e.g. Pet => PSPet."));
|
||||
cliOptions.add(new CliOption("commonVerbs", "PS common verb mappings. e.g. Delete=Remove:Patch=Update to map Delete with Remove and Patch with Update accordingly."));
|
||||
|
||||
}
|
||||
|
||||
@ -204,17 +510,17 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a PowerShell API client (beta). (The dependency C# API client needs to be generated separately.";
|
||||
return "Generates a PowerShell API client (beta)";
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
this.apiPackage = packageName + File.separator + "API";
|
||||
this.apiPackage = packageName + File.separator + "Api";
|
||||
this.modelPackage = packageName + File.separator + "Model";
|
||||
}
|
||||
|
||||
public void setCsharpClientPath(String csharpClientPath) {
|
||||
this.csharpClientPath = csharpClientPath;
|
||||
public void setPackageVersion(String packageVersion) {
|
||||
this.packageVersion = packageVersion;
|
||||
}
|
||||
|
||||
public void setSourceFolder(String sourceFolder) {
|
||||
@ -225,14 +531,36 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
this.packageGuid = packageGuid;
|
||||
}
|
||||
|
||||
public void setPowershellGalleryUrl(String powershellGalleryUrl) {
|
||||
this.powershellGalleryUrl = powershellGalleryUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (StringUtils.isEmpty(System.getenv("POWERSHELL_POST_PROCESS_FILE"))) {
|
||||
LOGGER.info("Environment variable POWERSHELL_POST_PROCESS_FILE not defined so the PowerShell code may not be properly formatted. To define it, try 'export POWERSHELL_POST_PROCESS_FILE=\"Edit-DTWBeautifyScript\"'");
|
||||
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("powershellGalleryUrl")) {
|
||||
setPowershellGalleryUrl((String) additionalProperties.get("powershellGalleryUrl"));
|
||||
} else {
|
||||
additionalProperties.put("powershellGalleryUrl", powershellGalleryUrl);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(powershellGalleryUrl)) {
|
||||
// get the last segment of the URL
|
||||
// e.g. https://www.powershellgallery.com/packages/PSTwitter => PSTwitter
|
||||
additionalProperties.put("powershellGalleryId", powershellGalleryUrl.replaceFirst(".*/([^/?]+).*", "$1"));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_PROJECT_GUID)) {
|
||||
setPackageGuid((String) additionalProperties.get(CodegenConstants.OPTIONAL_PROJECT_GUID));
|
||||
} else {
|
||||
additionalProperties.put("packageGuid", packageGuid);
|
||||
}
|
||||
additionalProperties.put("packageGuid", packageGuid);
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||
this.setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
||||
@ -240,10 +568,23 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("csharpClientPath")) {
|
||||
this.setCsharpClientPath((String) additionalProperties.get("csharpClientPath"));
|
||||
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
|
||||
this.setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
|
||||
} else {
|
||||
additionalProperties.put("csharpClientPath", csharpClientPath);
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("commonVerbs")) {
|
||||
String[] entries = ((String)additionalProperties.get("commonVerbs")).split(":");
|
||||
for (String entry : entries) {
|
||||
String[] pair = entry.split("=");
|
||||
if (pair.length == 2) {
|
||||
commonVerbs.put(pair[0], pair[1]);
|
||||
LOGGER.debug("Add commonVerbs: {} => {}", pair[0], pair[1]);
|
||||
} else {
|
||||
LOGGER.error("Failed to parse commonVerbs: {}", entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
|
||||
@ -267,15 +608,47 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
supportingFiles.add(new SupportingFile("Org.OpenAPITools.psm1.mustache", infrastructureFolder, packageName + ".psm1"));
|
||||
|
||||
// client/configuration
|
||||
supportingFiles.add(new SupportingFile("configuration.mustache", infrastructureFolder + "Client", apiNamePrefix + "Configuration.ps1"));
|
||||
|
||||
// private
|
||||
supportingFiles.add(new SupportingFile("Get-CommonParameters.ps1", infrastructureFolder + File.separator + "Private" + File.separator, "Get-CommonParameters.ps1"));
|
||||
supportingFiles.add(new SupportingFile("Out-DebugParameter.ps1", infrastructureFolder + File.separator + "Private" + File.separator, "Out-DebugParameter.ps1"));
|
||||
supportingFiles.add(new SupportingFile("api_client.mustache", infrastructureFolder + "Private", apiNamePrefix + "ApiClient.ps1"));
|
||||
supportingFiles.add(new SupportingFile("Get-CommonParameters.mustache", infrastructureFolder + File.separator + "Private" + File.separator, "Get-CommonParameters.ps1"));
|
||||
supportingFiles.add(new SupportingFile("Out-DebugParameter.mustache", infrastructureFolder + File.separator + "Private" + File.separator, "Out-DebugParameter.ps1"));
|
||||
supportingFiles.add(new SupportingFile("http_signature_auth.mustache", infrastructureFolder + "Private", apiNamePrefix + "HttpSignatureAuth.ps1"));
|
||||
supportingFiles.add(new SupportingFile("rsa_provider.mustache", infrastructureFolder + "Private", apiNamePrefix + "RSAEncryptionProvider.cs"));
|
||||
|
||||
|
||||
// en-US
|
||||
supportingFiles.add(new SupportingFile("about_Org.OpenAPITools.help.txt.mustache", infrastructureFolder + File.separator + "en-US" + File.separator + "about_" + packageName + ".help.txt"));
|
||||
|
||||
// appveyor
|
||||
supportingFiles.add(new SupportingFile("appveyor.mustache", "", "appveyor.yml"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
@Override
|
||||
public String escapeText(String input) {
|
||||
|
||||
if (input == null) {
|
||||
return input;
|
||||
}
|
||||
|
||||
// remove \t, \n, \r
|
||||
// replace \ with \\
|
||||
// replace " with \"
|
||||
// outter unescape to retain the original multi-byte characters
|
||||
// finally escalate characters avoiding code injection
|
||||
return escapeUnsafeCharacters(
|
||||
StringEscapeUtils.unescapeJava(
|
||||
StringEscapeUtils.escapeJava(input)
|
||||
.replace("\\/", "/"))
|
||||
.replaceAll("[\\t\\n\\r]", " ")
|
||||
.replace("\\", "\\\\")
|
||||
.replace("\"", "\"\""));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("#>", "#_>").replace("<#", "<_#");
|
||||
@ -287,9 +660,19 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
return input.replace("\"", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiTestFilename(String name) {
|
||||
return toApiFilename(name) + ".Tests";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelTestFilename(String name) {
|
||||
return toModelFilename(name) + ".Tests";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiTestFileFolder() {
|
||||
return (outputFolder + "/test").replace('/', File.separatorChar);
|
||||
return (outputFolder + "/" + apiTestPath).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -304,7 +687,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
@Override
|
||||
public String modelTestFileFolder() {
|
||||
return (outputFolder + "/test").replace('/', File.separatorChar);
|
||||
return (outputFolder + "/" + modelTestPath).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -320,7 +703,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
return "Var" + name;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -340,29 +723,29 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
name = name + "_" + modelNameSuffix;
|
||||
}
|
||||
|
||||
name = sanitizeName(name);
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
name = camelize(sanitizeName(name));
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
LOGGER.warn(name + " (reserved word or special variable name) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = camelize("model_" + name); // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
name = camelize("model_" + name); // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return "New-" + toModelName(name);
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -403,11 +786,9 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
Schema inner = ap.getItems();
|
||||
return getTypeDeclaration(inner) + "[]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
// TODO not sure if the following map/hash declaration is correct
|
||||
return "{String, " + getTypeDeclaration(inner) + "}";
|
||||
return "System.Collections.Hashtable";
|
||||
} else if (!languageSpecificPrimitives.contains(getSchemaType(p))) {
|
||||
return packageName + ".Model." + super.getTypeDeclaration(p);
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
@ -419,25 +800,61 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||
}
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
return sanitizeName(operationId);
|
||||
}
|
||||
|
||||
return camelize(sanitizeName(operationId));
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<String, CodegenModel>();
|
||||
HashMap<String, Integer> processedModelMaps = new HashMap<String, Integer>();
|
||||
|
||||
for (Object o : allModels) {
|
||||
HashMap<String, Object> h = (HashMap<String, Object>) o;
|
||||
CodegenModel m = (CodegenModel) h.get("model");
|
||||
modelMaps.put(m.classname, m);
|
||||
}
|
||||
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
int index = 0;
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
p.vendorExtensions.put("x-powershell-data-type", getPSDataType(p));
|
||||
p.vendorExtensions.put("x-powershell-example", constructExampleCode(p, modelMaps, processedModelMaps));
|
||||
p.vendorExtensions.put("x-index", index);
|
||||
index++;
|
||||
}
|
||||
|
||||
if (!op.vendorExtensions.containsKey("x-powershell-method-name")) { // x-powershell-method-name not set
|
||||
String methodName = toMethodName(op.operationId);
|
||||
op.vendorExtensions.put("x-powershell-method-name", methodName);
|
||||
op.vendorExtensions.put("x-powershell-method-name-lowercase", methodName);
|
||||
} else {
|
||||
op.vendorExtensions.put("x-powershell-method-name-lowercase", ((String) op.vendorExtensions.get("x-powershell-method-name")).toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
// detect duplicated method name
|
||||
if (methodNames.contains(op.vendorExtensions.get("x-powershell-method-name"))) {
|
||||
LOGGER.error("Duplicated method name found: {}", op.vendorExtensions.get("x-powershell-method-name"));
|
||||
} else {
|
||||
methodNames.add(op.vendorExtensions.get("x-powershell-method-name"));
|
||||
}
|
||||
|
||||
if (op.produces != null && op.produces.size() > 1) {
|
||||
op.vendorExtensions.put("x-powershell-select-accept", true);
|
||||
}
|
||||
}
|
||||
|
||||
processedModelMaps.clear();
|
||||
for (CodegenOperation operation : operationList) {
|
||||
for (CodegenParameter cp : operation.allParams) {
|
||||
cp.vendorExtensions.put("x-powershell-example", constructExampleCode(cp, modelMaps, processedModelMaps));
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
@ -448,7 +865,241 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
List<Object> models = (List<Object>) objs.get("models");
|
||||
// add x-index to properties
|
||||
ProcessUtils.addIndexToProperties(models);
|
||||
|
||||
// add x-data-type to store powershell type
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
|
||||
for (CodegenProperty cp : cm.allVars) {
|
||||
cp.vendorExtensions.put("x-powershell-data-type", getPSDataType(cp));
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// sanitize name
|
||||
name = sanitizeName(name);
|
||||
|
||||
// camelize the variable name
|
||||
// pet_id => PetId
|
||||
name = camelize(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (reserved word or special variable name) cannot be used in naming. Renamed to " + escapeReservedWord(name));
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
private String constructExampleCode(CodegenParameter codegenParameter, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
|
||||
if (codegenParameter.isListContainer) { // array
|
||||
return "@(" + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + ")";
|
||||
} else if (codegenParameter.isMapContainer) { // TODO: map, file type
|
||||
return "@{ \"Key\" = \"Value\" }";
|
||||
} else if (languageSpecificPrimitives.contains(codegenParameter.dataType) ||
|
||||
nullablePrimitives.contains(codegenParameter.dataType)) { // primitive type
|
||||
if ("String".equals(codegenParameter.dataType) || "Character".equals(codegenParameter.dataType)) {
|
||||
if (StringUtils.isEmpty(codegenParameter.example)) {
|
||||
return "\"" + codegenParameter.example + "\"";
|
||||
} else {
|
||||
return "\"" + codegenParameter.paramName + "_example\"";
|
||||
}
|
||||
} else if ("Boolean".equals(codegenParameter.dataType) ||
|
||||
"System.Nullable[Boolean]".equals(codegenParameter.dataType)) { // boolean
|
||||
if (Boolean.parseBoolean(codegenParameter.example)) {
|
||||
return "true";
|
||||
} else {
|
||||
return "false";
|
||||
}
|
||||
} else if ("URL".equals(codegenParameter.dataType)) { // URL
|
||||
return "URL(string: \"https://example.com\")!";
|
||||
} else if ("System.DateTime".equals(codegenParameter.dataType)) { // datetime or date
|
||||
return "Get-Date";
|
||||
} else { // numeric
|
||||
if (StringUtils.isEmpty(codegenParameter.example)) {
|
||||
return codegenParameter.example;
|
||||
} else {
|
||||
return "987";
|
||||
}
|
||||
}
|
||||
} else { // model
|
||||
// look up the model
|
||||
if (modelMaps.containsKey(codegenParameter.dataType)) {
|
||||
return constructExampleCode(modelMaps.get(codegenParameter.dataType), modelMaps, processedModelMap);
|
||||
} else {
|
||||
//LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
|
||||
return "TODO";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String constructExampleCode(CodegenProperty codegenProperty, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
|
||||
if (codegenProperty.isListContainer) { // array
|
||||
return "@(" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + ")";
|
||||
} else if (codegenProperty.isMapContainer) { // map
|
||||
return "\"TODO\"";
|
||||
} else if (languageSpecificPrimitives.contains(codegenProperty.dataType) || // primitive type
|
||||
nullablePrimitives.contains(codegenProperty.dataType)) { // nullable primitive type
|
||||
if ("String".equals(codegenProperty.dataType)) {
|
||||
if (StringUtils.isEmpty(codegenProperty.example)) {
|
||||
return "\"" + codegenProperty.example + "\"";
|
||||
} else {
|
||||
return "\"" + codegenProperty.name + "_example\"";
|
||||
}
|
||||
} else if ("Boolean".equals(codegenProperty.dataType) ||
|
||||
"System.Nullable[Boolean]".equals(codegenProperty.dataType)) { // boolean
|
||||
if (Boolean.parseBoolean(codegenProperty.example)) {
|
||||
return "$true";
|
||||
} else {
|
||||
return "$false";
|
||||
}
|
||||
} else if ("URL".equals(codegenProperty.dataType)) { // URL
|
||||
return "URL(string: \"https://example.com\")!";
|
||||
} else if ("System.DateTime".equals(codegenProperty.dataType)) { // datetime or date
|
||||
return "Get-Date";
|
||||
} else { // numeric
|
||||
if (StringUtils.isEmpty(codegenProperty.example)) {
|
||||
return codegenProperty.example;
|
||||
} else {
|
||||
return "123";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// look up the model
|
||||
if (modelMaps.containsKey(codegenProperty.dataType)) {
|
||||
return constructExampleCode(modelMaps.get(codegenProperty.dataType), modelMaps, processedModelMap);
|
||||
} else {
|
||||
//LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenProperty.dataType);
|
||||
return "\"TODO\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String constructExampleCode(CodegenModel codegenModel, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
|
||||
String example;
|
||||
|
||||
// break infinite recursion. Return, in case a model is already processed in the current context.
|
||||
String model = codegenModel.name;
|
||||
if (processedModelMap.containsKey(model)) {
|
||||
int count = processedModelMap.get(model);
|
||||
if (count == 1) {
|
||||
processedModelMap.put(model, 2);
|
||||
} else if (count == 2) {
|
||||
return "";
|
||||
} else {
|
||||
throw new RuntimeException("Invalid count when constructing example: " + count);
|
||||
}
|
||||
} else {
|
||||
processedModelMap.put(model, 1);
|
||||
}
|
||||
|
||||
example = "(Initialize-" + codegenModel.name;
|
||||
List<String> propertyExamples = new ArrayList<>();
|
||||
for (CodegenProperty codegenProperty : codegenModel.allVars) {
|
||||
propertyExamples.add("-" + codegenProperty.name + " " + constructExampleCode(codegenProperty, modelMaps, processedModelMap));
|
||||
}
|
||||
example += StringUtils.join(propertyExamples, " ");
|
||||
example += ")";
|
||||
return example;
|
||||
}
|
||||
|
||||
private String getPSDataType(CodegenProperty cp) {
|
||||
String dataType;
|
||||
if (cp.isPrimitiveType) {
|
||||
dataType = cp.dataType;
|
||||
if (!(cp.isString || cp.isFile || cp.isContainer)
|
||||
&& (cp.isNullable || !cp.required)) {
|
||||
dataType = "System.Nullable[" + dataType + "]";
|
||||
}
|
||||
return dataType;
|
||||
} else if (cp.isListContainer) { // array
|
||||
return getPSDataType(cp.items) + "[]";
|
||||
} else if (cp.isMapContainer) { // map
|
||||
return "System.Collections.Hashtable";
|
||||
} else { // model
|
||||
return "PSCustomObject";
|
||||
}
|
||||
}
|
||||
|
||||
private String getPSDataType(CodegenParameter cp) {
|
||||
String dataType;
|
||||
if (cp.isPrimitiveType) {
|
||||
dataType = cp.dataType;
|
||||
if (!(cp.isString || cp.isFile || cp.isContainer)
|
||||
&& (cp.isNullable || !cp.required)) {
|
||||
dataType = "System.Nullable[" + dataType + "]";
|
||||
}
|
||||
return dataType;
|
||||
} else if (cp.isListContainer) { // array
|
||||
return getPSDataType(cp.items) + "[]";
|
||||
} else if (cp.isMapContainer) { // map
|
||||
return "System.Collections.Hashtable";
|
||||
} else { // model
|
||||
return "PSCustomObject";
|
||||
}
|
||||
}
|
||||
|
||||
private String toMethodName(String operationId) {
|
||||
String methodName = camelize(operationId);
|
||||
|
||||
// check if method name starts with powershell verbs
|
||||
for (String verb : (HashSet<String>) powershellVerbs) {
|
||||
if (methodName.startsWith(verb)) {
|
||||
methodName = verb + "-" + apiNamePrefix + methodName.substring(verb.length());
|
||||
LOGGER.info("Naming the method using the PowerShell verb: {} => {}", operationId, methodName);
|
||||
return methodName;
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> entry : commonVerbs.entrySet()) {
|
||||
if (methodName.startsWith(entry.getKey())) {
|
||||
methodName = entry.getValue() + "-" + apiNamePrefix + methodName.substring(entry.getKey().length());
|
||||
LOGGER.info("Naming the method by mapping the common verbs (e.g. Create, Change) to PS verbs: {} => {}", operationId, methodName);
|
||||
return methodName;
|
||||
}
|
||||
}
|
||||
|
||||
// not using powershell verb
|
||||
return "Invoke-" + apiNamePrefix + methodName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessFile(File file, String fileType) {
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
String powershellPostProcessFile = System.getenv("POWERSHELL_POST_PROCESS_FILE");
|
||||
if (StringUtils.isEmpty(powershellPostProcessFile)) {
|
||||
return; // skip if POWERSHELL_POST_PROCESS_FILE env variable is not defined
|
||||
}
|
||||
|
||||
// only process files with ps extension
|
||||
if ("ps".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
String command = powershellPostProcessFile + " " + file.toString();
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command);
|
||||
int exitValue = p.waitFor();
|
||||
if (exitValue != 0) {
|
||||
LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue);
|
||||
} else {
|
||||
LOGGER.info("Successfully executed: " + command);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toRegularExpression(String pattern) {
|
||||
return escapeText(pattern);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -84,7 +84,6 @@ org.openapitools.codegen.languages.PhpSilexServerCodegen
|
||||
org.openapitools.codegen.languages.PhpSymfonyServerCodegen
|
||||
org.openapitools.codegen.languages.PhpZendExpressivePathHandlerServerCodegen
|
||||
org.openapitools.codegen.languages.PowerShellClientCodegen
|
||||
org.openapitools.codegen.languages.PowerShellExperimentalClientCodegen
|
||||
org.openapitools.codegen.languages.ProtobufSchemaCodegen
|
||||
org.openapitools.codegen.languages.PythonClientCodegen
|
||||
org.openapitools.codegen.languages.PythonClientExperimentalCodegen
|
||||
|
@ -1,66 +0,0 @@
|
||||
{{> partial_header}}
|
||||
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\{{{packageName}}}\" $_}
|
||||
|
||||
$Manifest = @{
|
||||
Path = "$ScriptDir\src\{{{packageName}}}\{{{packageName}}}.psd1"
|
||||
|
||||
Author = 'OpenAPI Generator Team'
|
||||
CompanyName = 'openapitools.org'
|
||||
Description = '{{{packageName}}} - the PowerShell module for {{{appName}}}'
|
||||
|
||||
ModuleVersion = '{{{packageVersion}}}'
|
||||
|
||||
RootModule = '{{{packageName}}}.psm1'
|
||||
Guid = '{{packageGuid}}' # Has to be static, otherwise each new build will be considered different module
|
||||
|
||||
PowerShellVersion = '3.0'
|
||||
|
||||
FunctionsToExport = $FunctionPath | Get-ChildItem -Filter *.ps1 | Get-FunctionsToExport
|
||||
|
||||
VariablesToExport = @()
|
||||
AliasesToExport = @()
|
||||
CmdletsToExport = @()
|
||||
|
||||
}
|
||||
|
||||
New-ModuleManifest @Manifest
|
@ -1,23 +0,0 @@
|
||||
{{>partial_header}}
|
||||
#region Import functions
|
||||
|
||||
# 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
|
@ -1,114 +0,0 @@
|
||||
# {{packageName}} - the PowerShell module for the {{appName}}
|
||||
|
||||
{{#appDescriptionWithNewLines}}
|
||||
{{{appDescriptionWithNewLines}}}
|
||||
|
||||
{{/appDescriptionWithNewLines}}
|
||||
This PowerShell module is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: {{appVersion}}
|
||||
- SDK version: {{packageVersion}}
|
||||
{{^hideGenerationTimestamp}}
|
||||
- Build date: {{generatedDate}}
|
||||
{{/hideGenerationTimestamp}}
|
||||
- Build package: {{generatorClass}}
|
||||
{{#infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/infoUrl}}
|
||||
|
||||
<a name="frameworks-supported"></a>
|
||||
## Frameworks supported
|
||||
- PowerShell 5.0 or later
|
||||
|
||||
<a name="dependencies"></a>
|
||||
## Dependencies
|
||||
|
||||
<a name="installation"></a>
|
||||
## Installation
|
||||
|
||||
{{#powershellGalleryUrl}}
|
||||
To install from PowerShell Gallery ({{{powershellGalleryUrl}}})
|
||||
```powershell
|
||||
Import-Module -Name {{{powershellGalleryId}}} -Verbose
|
||||
```
|
||||
{{/powershellGalleryUrl}}
|
||||
|
||||
To install from the source, run the following command to build and install the PowerShell module locally:
|
||||
```powershell
|
||||
Build.ps1
|
||||
Import-Module -Name '.\src\{{{packageName}}}' -Verbose
|
||||
```
|
||||
|
||||
To avoid function name collision, one can use `-Prefix`, e.g. `Import-Module -Name '.\src\{{{packageName}}}' -Prefix prefix`
|
||||
|
||||
To uninstall the module, simply run:
|
||||
```powershell
|
||||
Remove-Module -FullyQualifiedName @{ModuleName = "{{{packageName}}}"; ModuleVersion = "{{{packageVersion}}}"}
|
||||
```
|
||||
|
||||
<a name="tests"></a>
|
||||
## Tests
|
||||
|
||||
To install and run `Pester`, please execute the following commands in the terminal:
|
||||
|
||||
```powershell
|
||||
Install-module -name Pester -force
|
||||
|
||||
Invoker-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 *{{{basePath}}}*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{vendorExtensions.x-powershell-method-name}}**]({{apiDocPath}}{{classname}}.md#{{vendorExtensions.x-powershell-method-name-lowercase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{{summary}}}{{/summary}}
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
## Documentation for Models
|
||||
|
||||
{{#modelPackage}}
|
||||
{{#models}}{{#model}} - [{{{modelPackage}}}.{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
||||
{{/model}}{{/models}}
|
||||
{{/modelPackage}}
|
||||
{{^modelPackage}}
|
||||
No model defined in this package
|
||||
{{/modelPackage}}
|
||||
|
||||
## Documentation for Authorization
|
||||
|
||||
{{^authMethods}}
|
||||
All endpoints do not require authorization.
|
||||
{{/authMethods}}
|
||||
{{#authMethods}}
|
||||
{{#last}}
|
||||
Authentication schemes defined for the API:
|
||||
{{/last}}
|
||||
{{/authMethods}}
|
||||
{{#authMethods}}
|
||||
|
||||
### {{name}}
|
||||
|
||||
{{#isApiKey}}- **Type**: API key
|
||||
|
||||
- **API key parameter name**: {{keyParamName}}
|
||||
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: {{flow}}
|
||||
- **Authorization URL**: {{authorizationUrl}}
|
||||
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
||||
{{#scopes}} - {{scope}}: {{description}}
|
||||
{{/scopes}}
|
||||
{{/isOAuth}}
|
||||
|
||||
{{/authMethods}}
|
@ -1,27 +0,0 @@
|
||||
PSTOPIC
|
||||
about_{{{packageName}}}
|
||||
|
||||
SHORT DESCRIPTION
|
||||
{{{packageName}}} - the PowerShell module for the {{{appName}}}
|
||||
|
||||
LONG DESCRIPTION
|
||||
{{#appDescription}}
|
||||
{{{appDescription}}}
|
||||
|
||||
{{/appDescription}}
|
||||
This PowerShell module is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: {{appVersion}}
|
||||
- SDK version: {{packageVersion}}
|
||||
{{^hideGenerationTimestamp}}
|
||||
- Build date: {{generatedDate}}
|
||||
{{/hideGenerationTimestamp}}
|
||||
- Build package: {{{generatorClass}}}
|
||||
{{#infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/infoUrl}}
|
||||
|
||||
Frameworks supported:
|
||||
|
||||
* PowerShell 3.0+
|
||||
* .NET 4.0 or later
|
@ -1,235 +0,0 @@
|
||||
{{> partial_header}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
{{#summary}}{{{.}}}{{/summary}}{{^summary}}No summary available.{{/summary}}
|
||||
|
||||
.DESCRIPTION
|
||||
|
||||
{{#description}}{{{description}}}{{/description}}{{^description}}No description available.{{/description}}
|
||||
|
||||
{{#allParams}}
|
||||
.PARAMETER {{{paramName}}}
|
||||
{{#description}}{{{description}}}{{/description}}{{^description}}No description available.{{/description}}
|
||||
|
||||
{{/allParams}}
|
||||
{{#vendorExtensions.x-powershell-select-accept}}
|
||||
.PARAMETER ReturnType
|
||||
|
||||
Select the return type (optional): {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}
|
||||
|
||||
{{/vendorExtensions.x-powershell-select-accept}}
|
||||
.PARAMETER WithHttpInfo
|
||||
|
||||
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
|
||||
|
||||
.OUTPUTS
|
||||
|
||||
{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}None{{/returnType}}
|
||||
#>
|
||||
function {{{vendorExtensions.x-powershell-method-name}}} {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
{{#allParams}}
|
||||
[Parameter(Position = {{vendorExtensions.x-index}}{{#-first}}, ValueFromPipeline = $true{{/-first}}, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
|
||||
{{#isEnum}}
|
||||
{{#allowableValues}}
|
||||
[ValidateSet({{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}})]
|
||||
{{/allowableValues}}
|
||||
{{/isEnum}}
|
||||
[{{{vendorExtensions.x-powershell-data-type}}}]
|
||||
{{=<% %>=}}
|
||||
${<%paramName%>},
|
||||
<%={{ }}=%>
|
||||
{{/allParams}}
|
||||
{{#vendorExtensions.x-powershell-select-accept}}
|
||||
[String]
|
||||
[ValidateSet({{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}})]
|
||||
$ReturnType,
|
||||
{{/vendorExtensions.x-powershell-select-accept}}
|
||||
[Switch]
|
||||
$WithHttpInfo
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: {{{vendorExtensions.x-powershell-method-name}}}' | Write-Debug
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$LocalVarAccepts = @()
|
||||
$LocalVarContentTypes = @()
|
||||
$LocalVarQueryParameters = @{}
|
||||
$LocalVarHeaderParameters = @{}
|
||||
$LocalVarFormParameters = @{}
|
||||
$LocalVarPathParameters = @{}
|
||||
$LocalVarCookieParameters = @{}
|
||||
$LocalVarBodyParameter = $null
|
||||
|
||||
$Configuration = Get-{{{apiNamePrefix}}}Configuration
|
||||
{{#hasProduces}}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
$LocalVarAccepts = @({{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}})
|
||||
|
||||
{{/hasProduces}}
|
||||
{{#vendorExtensions.x-powershell-select-accept}}
|
||||
if ($ReturnType) {
|
||||
# use the return type (MIME) provided by the user
|
||||
$LocalVarAccepts = @($ReturnType)
|
||||
}
|
||||
|
||||
{{/vendorExtensions.x-powershell-select-accept}}
|
||||
{{#hasConsumes}}
|
||||
# HTTP header 'Content-Type'
|
||||
$LocalVarContentTypes = @({{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}})
|
||||
|
||||
{{/hasConsumes}}
|
||||
$LocalVarUri = '{{{path}}}'
|
||||
{{=< >=}}
|
||||
<#pathParams>
|
||||
if (!$<paramName>) {
|
||||
throw "Error! The required parameter `<paramName>` missing when calling <operationId>."
|
||||
}
|
||||
$LocalVarUri = $LocalVarUri.replace('{<baseName>}', $<paramName>)
|
||||
</pathParams>
|
||||
<={{ }}=>
|
||||
|
||||
{{#headerParams}}
|
||||
{{#required}}
|
||||
{{^isNullable}}
|
||||
if (!${{{paramName}}}) {
|
||||
throw "Error! The required parameter `{{paramName}}` missing when calling {{operationId}}."
|
||||
}
|
||||
$LocalVarHeaderParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
{{^isNullable}}
|
||||
if (${{{paramName}}}) {
|
||||
$LocalVarHeaderParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
}
|
||||
|
||||
{{/isNullable}}
|
||||
{{#isNullable}}
|
||||
$LocalVarHeaderParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{/headerParams}}
|
||||
{{#queryParams}}
|
||||
{{#required}}
|
||||
{{^isNullable}}
|
||||
if (!${{{paramName}}}) {
|
||||
throw "Error! The required parameter `{{paramName}}` missing when calling {{operationId}}."
|
||||
}
|
||||
$LocalVarQueryParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
{{^isNullable}}
|
||||
if (${{{paramName}}}) {
|
||||
$LocalVarQueryParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
}
|
||||
|
||||
{{/isNullable}}
|
||||
{{#isNullable}}
|
||||
$LocalVarQueryParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{/queryParams}}
|
||||
{{#formParams}}
|
||||
{{#required}}
|
||||
{{^isNullable}}
|
||||
if (!${{{paramName}}}) {
|
||||
throw "Error! The required parameter `{{paramName}}` missing when calling {{operationId}}."
|
||||
}
|
||||
$LocalVarFormParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
{{^isNullable}}
|
||||
if (${{{paramName}}}) {
|
||||
$LocalVarFormParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
}
|
||||
|
||||
{{/isNullable}}
|
||||
{{#isNullable}}
|
||||
$LocalVarFormParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}
|
||||
{{#required}}
|
||||
{{^isNullable}}
|
||||
if (!${{{paramName}}}) {
|
||||
throw "Error! The required parameter `{{paramName}}` missing when calling {{operationId}}."
|
||||
}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
$LocalVarBodyParameter = ${{{paramName}}} | ConvertTo-Json
|
||||
|
||||
{{/bodyParam}}
|
||||
{{#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)
|
||||
}
|
||||
{{/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)
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
{{#isKeyInCookie}}
|
||||
if ($Configuration["Cookie"]) {
|
||||
$LocalVarCookieParameters['{{{name}}}'] = $Configuration["Cookie"]
|
||||
Write-Verbose ("Using API key `{{{name}}}` in the cookie for authentication in {0}" -f $MyInvocation.MyCommand)
|
||||
}
|
||||
{{/isKeyInCookie}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasicBasic}}
|
||||
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)
|
||||
}
|
||||
{{/isBasicBasic}}
|
||||
{{#isBasicBearer}}
|
||||
if ($Configuration["AccessToken"]) {
|
||||
$LocalVarHeaderParameters['Authorization'] = "Bearer " + $Configuration["AccessToken"]
|
||||
Write-Verbose ("Using Bearer authentication in {0}" -f $MyInvocation.MyCommand)
|
||||
}
|
||||
{{/isBasicBearer}}
|
||||
|
||||
{{/authMethods}}
|
||||
$LocalVarResult = Invoke-{{{apiNamePrefix}}}ApiClient -Method '{{httpMethod}}' `
|
||||
-Uri $LocalVarUri `
|
||||
-Accepts $LocalVarAccepts `
|
||||
-ContentTypes $LocalVarContentTypes `
|
||||
-Body $LocalVarBodyParameter `
|
||||
-HeaderParameters $LocalVarHeaderParameters `
|
||||
-QueryParameters $LocalVarQueryParameters `
|
||||
-FormParameters $LocalVarFormParameters `
|
||||
-CookieParameters $LocalVarCookieParameters `
|
||||
-ReturnType "{{#returnType}}{{{.}}}{{/returnType}}"
|
||||
|
||||
if ($WithHttpInfo.IsPresent) {
|
||||
return $LocalVarResult
|
||||
} else {
|
||||
return $LocalVarResult["Response"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
@ -1,87 +0,0 @@
|
||||
# {{packageName}}.{{apiPackage}}.{{classname}}{{#description}}
|
||||
{{description}}{{/description}}
|
||||
|
||||
All URIs are relative to *{{{basePath}}}*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
{{#operations}}{{#operation}}[**{{vendorExtensions.x-powershell-method-name}}**]({{classname}}.md#{{vendorExtensions.x-powershell-method-name-lowercase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{/operation}}{{/operations}}
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
<a name="{{{vendorExtensions.x-powershell-method-name-lowercase}}}"></a>
|
||||
# **{{{vendorExtensions.x-powershell-method-name}}}**
|
||||
> {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{{vendorExtensions.x-powershell-method-name}}}<br>
|
||||
{{#allParams}}
|
||||
> [-{{paramName}}] <{{{vendorExtensions.x-powershell-data-type}}}><br>
|
||||
{{/allParams}}
|
||||
|
||||
{{{summary}}}{{#notes}}
|
||||
|
||||
{{{notes}}}{{/notes}}
|
||||
|
||||
### Example
|
||||
```powershell
|
||||
Import-Module -Name {{{packageName}}}
|
||||
|
||||
{{#hasAuthMethods}}
|
||||
$Configuration = Get-{{{packageName}}}Configuration
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
# Configure HTTP basic authorization: {{{name}}}
|
||||
$Configuration["Username"] = "YOUR_USERNAME";
|
||||
$Configuration["Password"] = "YOUR_PASSWORD";
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
# Configure API key authorization: {{{name}}}
|
||||
$Configuration["ApiKey"]["{{{keyParamName}}}"] = "YOUR_API_KEY"
|
||||
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
#$Configuration["ApiKeyPrefix"]["{{{keyParamName}}}"] = "Bearer"
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
# Configure OAuth2 access token for authorization: {{{name}}}
|
||||
$Configuration["AccessToken"] = "YOUR_ACCESS_TOKEN";
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
|
||||
{{/hasAuthMethods}}
|
||||
{{#allParams}}
|
||||
${{paramName}} = {{{vendorExtensions.x-powershell-example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||
{{/allParams}}
|
||||
|
||||
{{#summary}}
|
||||
# {{{.}}}
|
||||
{{/summary}}
|
||||
try {
|
||||
{{#returnType}}{{returnType}} $Result = {{/returnType}}{{{vendorExtensions.x-powershell-method-name}}}{{#allParams}} -{{paramName}} ${{paramName}}{{/allParams}}
|
||||
} catch {
|
||||
Write-Host ("Exception occured when calling {{{vendorExtensions.x-powershell-method-name}}}: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
|
||||
{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{#isContainer}}{{baseType}}{{/isContainer}}{{^isContainer}}{{dataType}}{{/isContainer}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
|
||||
{{/allParams}}
|
||||
|
||||
### Return type
|
||||
|
||||
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}}
|
||||
|
||||
### Authorization
|
||||
|
||||
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
|
||||
- **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
|
||||
|
||||
[[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)
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
@ -1,15 +0,0 @@
|
||||
{{> partial_header}}
|
||||
Describe -tag '{{{packageName}}}' -name '{{{classname}}}' {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
Context '{{{vendorExtensions.x-powershell-method-name}}}' {
|
||||
It 'Test {{{vendorExtensions.x-powershell-method-name}}}' {
|
||||
#$TestResult = Invoke-PetApiGetPetById{{#allParams}} -{{{paramName}}} "TEST_VALUE"{{/allParams}}
|
||||
#$TestResult | Should BeOfType TODO
|
||||
#$TestResult.property | Should Be 0
|
||||
}
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
{{> partial_header}}
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
{{#summary}}{{{.}}}{{/summary}}{{^summary}}No summary available.{{/summary}}
|
||||
|
||||
.DESCRIPTION
|
||||
|
||||
{{#description}}{{{description}}}{{/description}}{{^description}}No description available.{{/description}}
|
||||
|
||||
{{#allVars}}
|
||||
.PARAMETER {{{name}}}
|
||||
{{#description}}{{{description}}}{{/description}}{{^description}}No description available.{{/description}}
|
||||
|
||||
{{/allVars}}
|
||||
.OUTPUTS
|
||||
|
||||
{{{classname}}}<PSCustomObject>
|
||||
#>
|
||||
|
||||
function Initialize-{{{apiNamePrefix}}}{{{classname}}} {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
{{#allVars}}
|
||||
[Parameter(Position = {{vendorExtensions.x-index}}, ValueFromPipelineByPropertyName = $true)]
|
||||
{{#pattern}}
|
||||
[ValidatePattern("{{{.}}}")]
|
||||
{{/pattern}}
|
||||
{{#isEnum}}
|
||||
{{#allowableValues}}
|
||||
[ValidateSet({{#values}}"{{{.}}}"{{^-last}}, {{/-last}}{{/values}})]
|
||||
{{/allowableValues}}
|
||||
{{/isEnum}}
|
||||
[{{vendorExtensions.x-powershell-data-type}}]
|
||||
{{=<% %>=}}
|
||||
${<%name%>}<%^-last%>,<%/-last%>
|
||||
<%={{ }}=%>
|
||||
{{/allVars}}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Creating PSCustomObject: {{{packageName}}} => {{{apiNamePrefix}}}{{{classname}}}' | Write-Debug
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
{{#vars}}
|
||||
{{^isNullable}}
|
||||
{{#required}}
|
||||
if (!${{{name}}}) {
|
||||
throw "invalid value for '{{{name}}}', '{{{name}}}' cannot be null."
|
||||
}
|
||||
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
{{#hasValidation}}
|
||||
{{#maxLength}}
|
||||
if ({{^required}}!${{{name}}} -and {{/required}}${{{name}}}.length -gt {{{maxLength}}}) {
|
||||
throw "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}."
|
||||
}
|
||||
|
||||
{{/maxLength}}
|
||||
{{#minLength}}
|
||||
if ({{^required}}!${{{name}}} -and {{/required}}${{{name}}}.length -lt {{{minLength}}}) {
|
||||
throw "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}."
|
||||
}
|
||||
|
||||
{{/minLength}}
|
||||
{{#maximum}}
|
||||
if ({{^required}}!${{{name}}} -and {{/required}}${{{name}}} {{#exclusiveMaximum}}-ge{{/exclusiveMaximum}}{{^exclusiveMaximum}}-gt{{/exclusiveMaximum}} {{{maximum}}}) {
|
||||
throw "invalid value for '{{{name}}}', must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}."
|
||||
}
|
||||
|
||||
{{/maximum}}
|
||||
{{#minimum}}
|
||||
if ({{^required}}!${{{name}}} -and {{/required}}${{{name}}} {{#exclusiveMinimum}}-le{{/exclusiveMinimum}}{{^exclusiveMinimum}}-lt{{/exclusiveMinimum}} {{{minimum}}}) {
|
||||
throw "invalid value for '{{{name}}}', must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}."
|
||||
}
|
||||
|
||||
{{/minimum}}
|
||||
{{#maxItems}}
|
||||
if ({{^required}}!${{{name}}} -and {{/required}}${{{name}}}.length -gt {{{maxItems}}}) {
|
||||
throw "invalid value for '{{{name}}}', number of items must be less than or equal to {{{maxItems}}}."
|
||||
}
|
||||
|
||||
{{/maxItems}}
|
||||
{{#minItems}}
|
||||
if ({{^required}}!${{{name}}} -and {{/required}}${{{name}}}.length -lt {{{minItems}}}) {
|
||||
throw "invalid value for '{{{name}}}', number of items must be greater than or equal to {{{minItems}}}."
|
||||
}
|
||||
|
||||
{{/minItems}}
|
||||
{{/hasValidation}}
|
||||
{{/vars}}
|
||||
$PSO = [PSCustomObject]@{
|
||||
{{=<< >>=}}
|
||||
<<#allVars>>
|
||||
"<<baseName>>" = ${<<name>>}
|
||||
<</allVars>>
|
||||
<<={{ }}=>>
|
||||
}
|
||||
|
||||
return $PSO
|
||||
}
|
||||
}
|
||||
{{/model}}
|
||||
{{/models}}
|
@ -1,29 +0,0 @@
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
# {{{classname}}}
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{/vars}}
|
||||
|
||||
## Examples
|
||||
|
||||
- Prepare the resource
|
||||
```powershell
|
||||
Initialize-{{{packageName}}}{{{classname}}} {{#vars}} -{{name}} {{example}}{{#hasMore}} `
|
||||
{{/hasMore}}
|
||||
{{/vars}}
|
||||
|
||||
```
|
||||
|
||||
- Convert the resource to JSON
|
||||
```powershell
|
||||
${{className}} | Convert-ToJSON
|
||||
```
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
{{/model}}
|
||||
{{/models}}
|
@ -1,15 +0,0 @@
|
||||
{{> partial_header}}
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
Describe -tag '{{{packageName}}}' -name '{{{classname}}}' {
|
||||
Context '{{{classname}}}' {
|
||||
It 'New-{{{classname}}}' {
|
||||
# a simple test to create an object
|
||||
#$NewObject = New-{{{classname}}}{{#vars}} -{{name}} "TEST_VALUE"{{/vars}}
|
||||
#$NewObject | Should BeOfType {{classname}}
|
||||
#$NewObject.property | Should Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
{{/model}}
|
||||
{{/models}}
|
@ -1,3 +1,4 @@
|
||||
{{> partial_header}}
|
||||
function Get-FunctionsToExport {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
@ -38,17 +39,7 @@ function Get-FunctionsToExport {
|
||||
}
|
||||
|
||||
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
|
||||
$ClientPath = ("{{{csharpClientPath}}}" | Resolve-Path).ProviderPath
|
||||
$FunctionPath = 'API', 'Model' | ForEach-Object {Join-Path "$ScriptDir\src\{{{packageName}}}\" $_}
|
||||
$BinPath = "$ScriptDir\src\{{{packageName}}}\Bin"
|
||||
|
||||
Start-Process -FilePath "$ClientPath\build.bat" -WorkingDirectory $ClientPath -Wait -NoNewWindow
|
||||
|
||||
if (!(Test-Path "$ScriptDir\src\{{{packageName}}}\Bin" -PathType Container)) {
|
||||
New-Item "$ScriptDir\src\{{{packageName}}}\Bin" -ItemType Directory > $null
|
||||
}
|
||||
|
||||
Copy-Item "$ClientPath\bin\*.dll" $BinPath
|
||||
$FunctionPath = 'Api', 'Model', 'Client' | ForEach-Object {Join-Path "$ScriptDir\src\{{{packageName}}}\" $_}
|
||||
|
||||
$Manifest = @{
|
||||
Path = "$ScriptDir\src\{{{packageName}}}\{{{packageName}}}.psd1"
|
||||
@ -57,40 +48,19 @@ $Manifest = @{
|
||||
CompanyName = 'openapitools.org'
|
||||
Description = '{{{packageName}}} - the PowerShell module for {{{appName}}}'
|
||||
|
||||
ModuleVersion = '{{{packageVersion}}}'
|
||||
|
||||
RootModule = '{{{packageName}}}.psm1'
|
||||
Guid = '{{packageGuid}}' # Has to be static, otherwise each new build will be considered different module
|
||||
|
||||
PowerShellVersion = '3.0'
|
||||
|
||||
RequiredAssemblies = Get-ChildItem "$BinPath\*.dll" | ForEach-Object {
|
||||
Join-Path $_.Directory.Name $_.Name
|
||||
}
|
||||
|
||||
FunctionsToExport = $FunctionPath | Get-ChildItem -Filter *.ps1 | Get-FunctionsToExport
|
||||
|
||||
VariablesToExport = @()
|
||||
AliasesToExport = @()
|
||||
CmdletsToExport = @()
|
||||
|
||||
# Should we use prefix to prevent command name collisions?
|
||||
# https://www.sapien.com/blog/2016/02/15/use-prefixes-to-prevent-command-name-collision/
|
||||
#
|
||||
# Kirk Munro recommends against it:
|
||||
# https://www.sapien.com/blog/2016/02/15/use-prefixes-to-prevent-command-name-collision/#comment-20820
|
||||
#
|
||||
# If not, we'd need to generate functions name with prefix. For examples,
|
||||
#
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-first}}
|
||||
# DefaultCommandPrefix = '{{{classname}}}'
|
||||
{{/-first}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
}
|
||||
|
||||
New-ModuleManifest @Manifest
|
||||
|
@ -1,14 +0,0 @@
|
||||
<#
|
||||
.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
|
||||
}
|
@ -1,33 +1,23 @@
|
||||
{{>partial_header}}
|
||||
#region Import functions
|
||||
|
||||
'API', 'Model', 'Private' | Get-ChildItem -Path {
|
||||
# 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-Verbose "Importing file: $($_.BaseName)"
|
||||
Write-Debug "Importing file: $($_.BaseName)"
|
||||
try {
|
||||
. $_.FullName
|
||||
} catch {
|
||||
Write-Verbose "Can't import function!"
|
||||
Write-Error -Message "Failed to import function $($_.Fullname): $_"
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Initialize APIs
|
||||
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-first}}
|
||||
'Creating object: {{{packageName}}}.Api.{{{classname}}}' | Write-Verbose
|
||||
$Script:{{{classname}}}= New-Object -TypeName {{{packageName}}}.Api.{{{classname}}} -ArgumentList @($null)
|
||||
|
||||
{{/-first}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
#endregion
|
||||
|
@ -1,37 +0,0 @@
|
||||
<#
|
||||
.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()) {
|
||||
$_
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
|
||||
{{#appDescriptionWithNewLines}}
|
||||
{{{appDescriptionWithNewLines}}}
|
||||
{{/appDescriptionWithNewLines}}
|
||||
|
||||
{{/appDescriptionWithNewLines}}
|
||||
This PowerShell module is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: {{appVersion}}
|
||||
@ -18,21 +18,97 @@ This PowerShell module is automatically generated by the [OpenAPI Generator](htt
|
||||
|
||||
<a name="frameworks-supported"></a>
|
||||
## Frameworks supported
|
||||
- PowerShell 3.0 or later
|
||||
- PowerShell 5.0 or later
|
||||
|
||||
<a name="dependencies"></a>
|
||||
## Dependencies
|
||||
- C# API client generated by OpenAPI Generator AND should be located in {{{csharpClientPath}}} as stated in Build.ps1
|
||||
|
||||
<a name="installation"></a>
|
||||
## Installation
|
||||
Run the following command to generate the DLL
|
||||
- [Windows] `Build.ps1`
|
||||
|
||||
Then import module from the .\src\{{{packageName}}} folder:
|
||||
{{#powershellGalleryUrl}}
|
||||
To install from PowerShell Gallery ({{{powershellGalleryUrl}}})
|
||||
```powershell
|
||||
using {{packageName}}.{{apiPackage}};
|
||||
using {{packageName}}.Client;
|
||||
using {{packageName}}.{{modelPackage}};
|
||||
Import-Module -Name {{{powershellGalleryId}}} -Verbose
|
||||
```
|
||||
{{/powershellGalleryUrl}}
|
||||
|
||||
To install from the source, run the following command to build and install the PowerShell module locally:
|
||||
```powershell
|
||||
Build.ps1
|
||||
Import-Module -Name '.\src\{{{packageName}}}' -Verbose
|
||||
```
|
||||
|
||||
To avoid function name collision, one can use `-Prefix`, e.g. `Import-Module -Name '.\src\{{{packageName}}}' -Prefix prefix`
|
||||
|
||||
To uninstall the module, simply run:
|
||||
```powershell
|
||||
Remove-Module -FullyQualifiedName @{ModuleName = "{{{packageName}}}"; ModuleVersion = "{{{packageVersion}}}"}
|
||||
```
|
||||
|
||||
<a name="tests"></a>
|
||||
## Tests
|
||||
|
||||
To install and run `Pester`, please execute the following commands in the terminal:
|
||||
|
||||
```powershell
|
||||
Install-module -name Pester -force
|
||||
|
||||
Invoker-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 *{{{basePath}}}*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{vendorExtensions.x-powershell-method-name}}**]({{apiDocPath}}{{classname}}.md#{{vendorExtensions.x-powershell-method-name-lowercase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{{summary}}}{{/summary}}
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
## Documentation for Models
|
||||
|
||||
{{#modelPackage}}
|
||||
{{#models}}{{#model}} - [{{{modelPackage}}}.{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
||||
{{/model}}{{/models}}
|
||||
{{/modelPackage}}
|
||||
{{^modelPackage}}
|
||||
No model defined in this package
|
||||
{{/modelPackage}}
|
||||
|
||||
## Documentation for Authorization
|
||||
|
||||
{{^authMethods}}
|
||||
All endpoints do not require authorization.
|
||||
{{/authMethods}}
|
||||
{{#authMethods}}
|
||||
{{#last}}
|
||||
Authentication schemes defined for the API:
|
||||
{{/last}}
|
||||
{{/authMethods}}
|
||||
{{#authMethods}}
|
||||
|
||||
### {{name}}
|
||||
|
||||
{{#isApiKey}}- **Type**: API key
|
||||
|
||||
- **API key parameter name**: {{keyParamName}}
|
||||
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: {{flow}}
|
||||
- **Authorization URL**: {{authorizationUrl}}
|
||||
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
||||
{{#scopes}} - {{scope}}: {{description}}
|
||||
{{/scopes}}
|
||||
{{/isOAuth}}
|
||||
|
||||
{{/authMethods}}
|
||||
|
@ -1,28 +1,233 @@
|
||||
{{> partial_header}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
function Invoke-{{{classname}}}{{{operationId}}} {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
{{#summary}}{{{.}}}{{/summary}}{{^summary}}No summary available.{{/summary}}
|
||||
|
||||
.DESCRIPTION
|
||||
|
||||
{{#description}}{{{description}}}{{/description}}{{^description}}No description available.{{/description}}
|
||||
|
||||
{{#allParams}}
|
||||
.PARAMETER {{{paramName}}}
|
||||
{{#description}}{{{description}}}{{/description}}{{^description}}No description available.{{/description}}
|
||||
|
||||
{{/allParams}}
|
||||
{{#vendorExtensions.x-powershell-select-accept}}
|
||||
.PARAMETER ReturnType
|
||||
|
||||
Select the return type (optional): {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}
|
||||
|
||||
{{/vendorExtensions.x-powershell-select-accept}}
|
||||
.PARAMETER WithHttpInfo
|
||||
|
||||
A switch when turned on will return a hash table of Response, StatusCode and Headers instead of just the Response
|
||||
|
||||
.OUTPUTS
|
||||
|
||||
{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}None{{/returnType}}
|
||||
#>
|
||||
function {{{vendorExtensions.x-powershell-method-name}}} {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
{{#allParams}}
|
||||
[Parameter(Position = {{vendorExtensions.x-index}}, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = {{#required}}$true{{/required}}{{^required}}$false{{/required}})]
|
||||
[{{^isContainer}}{{^isPrimitiveType}}{{^isFile}}{{{packageName}}}.Model.{{/isFile}}{{/isPrimitiveType}}{{/isContainer}}{{{dataType}}}]
|
||||
[Parameter(Position = {{vendorExtensions.x-index}}{{#-first}}, ValueFromPipeline = $true{{/-first}}, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
|
||||
{{#isEnum}}
|
||||
{{#allowableValues}}
|
||||
[ValidateSet({{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}})]
|
||||
{{/allowableValues}}
|
||||
{{/isEnum}}
|
||||
[{{{vendorExtensions.x-powershell-data-type}}}]
|
||||
{{=<% %>=}}
|
||||
${<%paramName%>}<%^-last%>,<%/-last%>
|
||||
${<%paramName%>},
|
||||
<%={{ }}=%>
|
||||
{{/allParams}}
|
||||
{{#vendorExtensions.x-powershell-select-accept}}
|
||||
[String]
|
||||
[ValidateSet({{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}})]
|
||||
$ReturnType,
|
||||
{{/vendorExtensions.x-powershell-select-accept}}
|
||||
[Switch]
|
||||
$WithHttpInfo
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: {{{classname}}}-{{{operationId}}}' | Write-Verbose
|
||||
'Calling method: {{{vendorExtensions.x-powershell-method-name}}}' | Write-Debug
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:{{{classname}}}.{{{operationId}}}(
|
||||
{{#allParams}}
|
||||
{{=<% %>=}}
|
||||
${<%paramName%>}<%^-last%>,<%/-last%>
|
||||
<%={{ }}=%>
|
||||
{{/allParams}}
|
||||
)
|
||||
$LocalVarAccepts = @()
|
||||
$LocalVarContentTypes = @()
|
||||
$LocalVarQueryParameters = @{}
|
||||
$LocalVarHeaderParameters = @{}
|
||||
$LocalVarFormParameters = @{}
|
||||
$LocalVarPathParameters = @{}
|
||||
$LocalVarCookieParameters = @{}
|
||||
$LocalVarBodyParameter = $null
|
||||
|
||||
$Configuration = Get-{{{apiNamePrefix}}}Configuration
|
||||
{{#hasProduces}}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
$LocalVarAccepts = @({{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}})
|
||||
|
||||
{{/hasProduces}}
|
||||
{{#vendorExtensions.x-powershell-select-accept}}
|
||||
if ($ReturnType) {
|
||||
# use the return type (MIME) provided by the user
|
||||
$LocalVarAccepts = @($ReturnType)
|
||||
}
|
||||
|
||||
{{/vendorExtensions.x-powershell-select-accept}}
|
||||
{{#hasConsumes}}
|
||||
# HTTP header 'Content-Type'
|
||||
$LocalVarContentTypes = @({{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}})
|
||||
|
||||
{{/hasConsumes}}
|
||||
$LocalVarUri = '{{{path}}}'
|
||||
{{=< >=}}
|
||||
<#pathParams>
|
||||
if (!$<paramName>) {
|
||||
throw "Error! The required parameter `<paramName>` missing when calling <operationId>."
|
||||
}
|
||||
$LocalVarUri = $LocalVarUri.replace('{<baseName>}', $<paramName>)
|
||||
</pathParams>
|
||||
<={{ }}=>
|
||||
|
||||
{{#headerParams}}
|
||||
{{#required}}
|
||||
{{^isNullable}}
|
||||
if (!${{{paramName}}}) {
|
||||
throw "Error! The required parameter `{{paramName}}` missing when calling {{operationId}}."
|
||||
}
|
||||
$LocalVarHeaderParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
{{^isNullable}}
|
||||
if (${{{paramName}}}) {
|
||||
$LocalVarHeaderParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
}
|
||||
|
||||
{{/isNullable}}
|
||||
{{#isNullable}}
|
||||
$LocalVarHeaderParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{/headerParams}}
|
||||
{{#queryParams}}
|
||||
{{#required}}
|
||||
{{^isNullable}}
|
||||
if (!${{{paramName}}}) {
|
||||
throw "Error! The required parameter `{{paramName}}` missing when calling {{operationId}}."
|
||||
}
|
||||
$LocalVarQueryParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
{{^isNullable}}
|
||||
if (${{{paramName}}}) {
|
||||
$LocalVarQueryParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
}
|
||||
|
||||
{{/isNullable}}
|
||||
{{#isNullable}}
|
||||
$LocalVarQueryParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{/queryParams}}
|
||||
{{#formParams}}
|
||||
{{#required}}
|
||||
{{^isNullable}}
|
||||
if (!${{{paramName}}}) {
|
||||
throw "Error! The required parameter `{{paramName}}` missing when calling {{operationId}}."
|
||||
}
|
||||
$LocalVarFormParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
{{^isNullable}}
|
||||
if (${{{paramName}}}) {
|
||||
$LocalVarFormParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
}
|
||||
|
||||
{{/isNullable}}
|
||||
{{#isNullable}}
|
||||
$LocalVarFormParameters['{{baseName}}'] = ${{{paramName}}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}
|
||||
{{#required}}
|
||||
{{^isNullable}}
|
||||
if (!${{{paramName}}}) {
|
||||
throw "Error! The required parameter `{{paramName}}` missing when calling {{operationId}}."
|
||||
}
|
||||
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
$LocalVarBodyParameter = ${{{paramName}}} | ConvertTo-Json
|
||||
|
||||
{{/bodyParam}}
|
||||
{{#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)
|
||||
}
|
||||
{{/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)
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
{{#isKeyInCookie}}
|
||||
if ($Configuration["Cookie"]) {
|
||||
$LocalVarCookieParameters['{{{name}}}'] = $Configuration["Cookie"]
|
||||
Write-Verbose ("Using API key `{{{name}}}` in the cookie for authentication in {0}" -f $MyInvocation.MyCommand)
|
||||
}
|
||||
{{/isKeyInCookie}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasicBasic}}
|
||||
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)
|
||||
}
|
||||
{{/isBasicBasic}}
|
||||
{{#isBasicBearer}}
|
||||
if ($Configuration["AccessToken"]) {
|
||||
$LocalVarHeaderParameters['Authorization'] = "Bearer " + $Configuration["AccessToken"]
|
||||
Write-Verbose ("Using Bearer authentication in {0}" -f $MyInvocation.MyCommand)
|
||||
}
|
||||
{{/isBasicBearer}}
|
||||
|
||||
{{/authMethods}}
|
||||
$LocalVarResult = Invoke-{{{apiNamePrefix}}}ApiClient -Method '{{httpMethod}}' `
|
||||
-Uri $LocalVarUri `
|
||||
-Accepts $LocalVarAccepts `
|
||||
-ContentTypes $LocalVarContentTypes `
|
||||
-Body $LocalVarBodyParameter `
|
||||
-HeaderParameters $LocalVarHeaderParameters `
|
||||
-QueryParameters $LocalVarQueryParameters `
|
||||
-FormParameters $LocalVarFormParameters `
|
||||
-CookieParameters $LocalVarCookieParameters `
|
||||
-ReturnType "{{#returnType}}{{{.}}}{{/returnType}}"
|
||||
|
||||
if ($WithHttpInfo.IsPresent) {
|
||||
return $LocalVarResult
|
||||
} else {
|
||||
return $LocalVarResult["Response"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,77 +5,59 @@ All URIs are relative to *{{{basePath}}}*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{#operations}}{{#operation}}[**{{vendorExtensions.x-powershell-method-name}}**]({{classname}}.md#{{vendorExtensions.x-powershell-method-name-lowercase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{/operation}}{{/operations}}
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
<a name="{{{operationIdLowerCase}}}"></a>
|
||||
# **{{{operationId}}}**
|
||||
> {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
<a name="{{{vendorExtensions.x-powershell-method-name-lowercase}}}"></a>
|
||||
# **{{{vendorExtensions.x-powershell-method-name}}}**
|
||||
> {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{{vendorExtensions.x-powershell-method-name}}}<br>
|
||||
{{#allParams}}
|
||||
> [-{{paramName}}] <{{{vendorExtensions.x-powershell-data-type}}}><br>
|
||||
{{/allParams}}
|
||||
|
||||
{{{summary}}}{{#notes}}
|
||||
|
||||
{{{notes}}}{{/notes}}
|
||||
|
||||
### Example
|
||||
```csharp
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using {{packageName}}.{{apiPackage}};
|
||||
using {{packageName}}.Client;
|
||||
using {{packageName}}.{{modelPackage}};
|
||||
```powershell
|
||||
Import-Module -Name {{{packageName}}}
|
||||
|
||||
namespace Example
|
||||
{
|
||||
public class {{operationId}}Example
|
||||
{
|
||||
public void main()
|
||||
{
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
// Configure HTTP basic authorization: {{{name}}}
|
||||
Configuration.Default.Username = "YOUR_USERNAME";
|
||||
Configuration.Default.Password = "YOUR_PASSWORD";
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
// Configure API key authorization: {{{name}}}
|
||||
Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY");
|
||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
// Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
// Configure OAuth2 access token for authorization: {{{name}}}
|
||||
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
{{#hasAuthMethods}}
|
||||
$Configuration = Get-{{{packageName}}}Configuration
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
# Configure HTTP basic authorization: {{{name}}}
|
||||
$Configuration["Username"] = "YOUR_USERNAME";
|
||||
$Configuration["Password"] = "YOUR_PASSWORD";
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
# Configure API key authorization: {{{name}}}
|
||||
$Configuration["ApiKey"]["{{{keyParamName}}}"] = "YOUR_API_KEY"
|
||||
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
#$Configuration["ApiKeyPrefix"]["{{{keyParamName}}}"] = "Bearer"
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
# Configure OAuth2 access token for authorization: {{{name}}}
|
||||
$Configuration["AccessToken"] = "YOUR_ACCESS_TOKEN";
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
|
||||
{{/hasAuthMethods}}
|
||||
var apiInstance = new {{classname}}();
|
||||
{{#allParams}}
|
||||
{{#isPrimitiveType}}
|
||||
var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
var {{paramName}} = new {{{dataType}}}(); // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/allParams}}
|
||||
{{/hasAuthMethods}}
|
||||
{{#allParams}}
|
||||
${{paramName}} = {{{vendorExtensions.x-powershell-example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||
{{/allParams}}
|
||||
|
||||
try
|
||||
{
|
||||
{{#summary}}
|
||||
// {{{.}}}
|
||||
{{/summary}}
|
||||
{{#returnType}}{{returnType}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
||||
Debug.WriteLine(result);{{/returnType}}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message );
|
||||
}
|
||||
}
|
||||
}
|
||||
{{#summary}}
|
||||
# {{{.}}}
|
||||
{{/summary}}
|
||||
try {
|
||||
{{#returnType}}{{returnType}} $Result = {{/returnType}}{{{vendorExtensions.x-powershell-method-name}}}{{#allParams}} -{{paramName}} ${{paramName}}{{/allParams}}
|
||||
} catch {
|
||||
Write-Host ("Exception occured when calling {{{vendorExtensions.x-powershell-method-name}}}: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -1,14 +1,12 @@
|
||||
# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
# Please replace "TEST_VALUE" with a proper value and uncomment the code for testing the function
|
||||
|
||||
Describe '{{{packageName}}} {{{classname}}}' {
|
||||
{{> partial_header}}
|
||||
Describe -tag '{{{packageName}}}' -name '{{{classname}}}' {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
Context '{{{classname}}}' {
|
||||
It 'Invoke-{{{classname}}}{{{operationId}}}' {
|
||||
$ret = Invoke-PetApiGetPetById{{#allParams}} -{{{paramName}}} "TEST_VALUE"{{/allParams}}
|
||||
#$ret | Should BeOfType {{{packageName}}}.Model.ModelNameHere
|
||||
#$ret.property | Should Be 0
|
||||
Context '{{{vendorExtensions.x-powershell-method-name}}}' {
|
||||
It 'Test {{{vendorExtensions.x-powershell-method-name}}}' {
|
||||
#$TestResult = Invoke-PetApiGetPetById{{#allParams}} -{{{paramName}}} "TEST_VALUE"{{/allParams}}
|
||||
#$TestResult | Should BeOfType TODO
|
||||
#$TestResult.property | Should Be 0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,28 +1,106 @@
|
||||
{{> partial_header}}
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
function New-{{{classname}}} {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
{{#summary}}{{{.}}}{{/summary}}{{^summary}}No summary available.{{/summary}}
|
||||
|
||||
.DESCRIPTION
|
||||
|
||||
{{#description}}{{{description}}}{{/description}}{{^description}}No description available.{{/description}}
|
||||
|
||||
{{#allVars}}
|
||||
.PARAMETER {{{name}}}
|
||||
{{#description}}{{{description}}}{{/description}}{{^description}}No description available.{{/description}}
|
||||
|
||||
{{/allVars}}
|
||||
.OUTPUTS
|
||||
|
||||
{{{classname}}}<PSCustomObject>
|
||||
#>
|
||||
|
||||
function Initialize-{{{apiNamePrefix}}}{{{classname}}} {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
{{#vars}}
|
||||
[Parameter(Position = {{vendorExtensions.x-index}}, ValueFromPipelineByPropertyName = $true{{#required}}, Mandatory = $true{{/required}})]
|
||||
[{{#isString}}{{{dataType}}}{{/isString}}{{^isString}}{{#isListContainer}}{{{dataType}}}{{/isListContainer}}{{^isListContainer}}{{#isPrimitiveType}}{{^required}}System.Nullable[{{/required}}{{dataType}}{{^required}}]{{/required}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{dataType}}{{/isPrimitiveType}}{{/isListContainer}}{{/isString}}]
|
||||
{{#allVars}}
|
||||
[Parameter(Position = {{vendorExtensions.x-index}}, ValueFromPipelineByPropertyName = $true)]
|
||||
{{#pattern}}
|
||||
[ValidatePattern("{{{.}}}")]
|
||||
{{/pattern}}
|
||||
{{#isEnum}}
|
||||
{{#allowableValues}}
|
||||
[ValidateSet({{#values}}"{{{.}}}"{{^-last}}, {{/-last}}{{/values}})]
|
||||
{{/allowableValues}}
|
||||
{{/isEnum}}
|
||||
[{{vendorExtensions.x-powershell-data-type}}]
|
||||
{{=<% %>=}}
|
||||
${<%name%>}<%^-last%>,<%/-last%>
|
||||
<%={{ }}=%>
|
||||
{{/vars}}
|
||||
{{/allVars}}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Creating object: {{{packageName}}}.Model.{{{classname}}}' | Write-Verbose
|
||||
'Creating PSCustomObject: {{{packageName}}} => {{{apiNamePrefix}}}{{{classname}}}' | Write-Debug
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
New-Object -TypeName {{{packageName}}}.Model.{{{classname}}} -ArgumentList @(
|
||||
{{#vars}}
|
||||
{{=<% %>=}}
|
||||
${<%name%>}<%^-last%>,<%/-last%>
|
||||
<%={{ }}=%>
|
||||
{{/vars}}
|
||||
)
|
||||
{{#vars}}
|
||||
{{^isNullable}}
|
||||
{{#required}}
|
||||
if (!${{{name}}}) {
|
||||
throw "invalid value for '{{{name}}}', '{{{name}}}' cannot be null."
|
||||
}
|
||||
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
{{#hasValidation}}
|
||||
{{#maxLength}}
|
||||
if ({{^required}}!${{{name}}} -and {{/required}}${{{name}}}.length -gt {{{maxLength}}}) {
|
||||
throw "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}."
|
||||
}
|
||||
|
||||
{{/maxLength}}
|
||||
{{#minLength}}
|
||||
if ({{^required}}!${{{name}}} -and {{/required}}${{{name}}}.length -lt {{{minLength}}}) {
|
||||
throw "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}."
|
||||
}
|
||||
|
||||
{{/minLength}}
|
||||
{{#maximum}}
|
||||
if ({{^required}}!${{{name}}} -and {{/required}}${{{name}}} {{#exclusiveMaximum}}-ge{{/exclusiveMaximum}}{{^exclusiveMaximum}}-gt{{/exclusiveMaximum}} {{{maximum}}}) {
|
||||
throw "invalid value for '{{{name}}}', must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}."
|
||||
}
|
||||
|
||||
{{/maximum}}
|
||||
{{#minimum}}
|
||||
if ({{^required}}!${{{name}}} -and {{/required}}${{{name}}} {{#exclusiveMinimum}}-le{{/exclusiveMinimum}}{{^exclusiveMinimum}}-lt{{/exclusiveMinimum}} {{{minimum}}}) {
|
||||
throw "invalid value for '{{{name}}}', must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}."
|
||||
}
|
||||
|
||||
{{/minimum}}
|
||||
{{#maxItems}}
|
||||
if ({{^required}}!${{{name}}} -and {{/required}}${{{name}}}.length -gt {{{maxItems}}}) {
|
||||
throw "invalid value for '{{{name}}}', number of items must be less than or equal to {{{maxItems}}}."
|
||||
}
|
||||
|
||||
{{/maxItems}}
|
||||
{{#minItems}}
|
||||
if ({{^required}}!${{{name}}} -and {{/required}}${{{name}}}.length -lt {{{minItems}}}) {
|
||||
throw "invalid value for '{{{name}}}', number of items must be greater than or equal to {{{minItems}}}."
|
||||
}
|
||||
|
||||
{{/minItems}}
|
||||
{{/hasValidation}}
|
||||
{{/vars}}
|
||||
$PSO = [PSCustomObject]@{
|
||||
{{=<< >>=}}
|
||||
<<#allVars>>
|
||||
"<<baseName>>" = ${<<name>>}
|
||||
<</allVars>>
|
||||
<<={{ }}=>>
|
||||
}
|
||||
|
||||
return $PSO
|
||||
}
|
||||
}
|
||||
{{/model}}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
# {{{packageName}}}.{{modelPackage}}.{{{classname}}}
|
||||
# {{{classname}}}
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
@ -8,6 +8,21 @@ Name | Type | Description | Notes
|
||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{/vars}}
|
||||
|
||||
## Examples
|
||||
|
||||
- Prepare the resource
|
||||
```powershell
|
||||
Initialize-{{{packageName}}}{{{classname}}} {{#vars}} -{{name}} {{example}}{{#hasMore}} `
|
||||
{{/hasMore}}
|
||||
{{/vars}}
|
||||
|
||||
```
|
||||
|
||||
- Convert the resource to JSON
|
||||
```powershell
|
||||
${{className}} | Convert-ToJSON
|
||||
```
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
{{/model}}
|
||||
|
@ -1,6 +1,15 @@
|
||||
{{> partial_header}}
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
## TODO we need to update the template to test the model files
|
||||
|
||||
Describe -tag '{{{packageName}}}' -name '{{{classname}}}' {
|
||||
Context '{{{classname}}}' {
|
||||
It 'New-{{{classname}}}' {
|
||||
# a simple test to create an object
|
||||
#$NewObject = New-{{{classname}}}{{#vars}} -{{name}} "TEST_VALUE"{{/vars}}
|
||||
#$NewObject | Should BeOfType {{classname}}
|
||||
#$NewObject.property | Should Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
@ -1,23 +0,0 @@
|
||||
# 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
|
@ -1 +0,0 @@
|
||||
4.3.1-SNAPSHOT
|
@ -1,72 +0,0 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# Version: 1.0.0
|
||||
# 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\PSPetstore\" $_}
|
||||
|
||||
$Manifest = @{
|
||||
Path = "$ScriptDir\src\PSPetstore\PSPetstore.psd1"
|
||||
|
||||
Author = 'OpenAPI Generator Team'
|
||||
CompanyName = 'openapitools.org'
|
||||
Description = 'PSPetstore - the PowerShell module for OpenAPI Petstore'
|
||||
|
||||
ModuleVersion = '0.1.2'
|
||||
|
||||
RootModule = 'PSPetstore.psm1'
|
||||
Guid = 'a27b908d-2a20-467f-bc32-af6f3a654ac5' # Has to be static, otherwise each new build will be considered different module
|
||||
|
||||
PowerShellVersion = '3.0'
|
||||
|
||||
FunctionsToExport = $FunctionPath | Get-ChildItem -Filter *.ps1 | Get-FunctionsToExport
|
||||
|
||||
VariablesToExport = @()
|
||||
AliasesToExport = @()
|
||||
CmdletsToExport = @()
|
||||
|
||||
}
|
||||
|
||||
New-ModuleManifest @Manifest
|
@ -1,120 +0,0 @@
|
||||
# PSPetstore - the PowerShell module for the OpenAPI Petstore
|
||||
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
This PowerShell module is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: 1.0.0
|
||||
- SDK version: 0.1.2
|
||||
- Build package: org.openapitools.codegen.languages.PowerShellExperimentalClientCodegen
|
||||
|
||||
<a name="frameworks-supported"></a>
|
||||
## Frameworks supported
|
||||
- PowerShell 5.0 or later
|
||||
|
||||
<a name="dependencies"></a>
|
||||
## Dependencies
|
||||
|
||||
<a name="installation"></a>
|
||||
## Installation
|
||||
|
||||
To install from PowerShell Gallery (https://www.powershellgallery.com/packages/PSPetstore)
|
||||
```powershell
|
||||
Import-Module -Name PSPetstore -Verbose
|
||||
```
|
||||
|
||||
To install from the source, run the following command to build and install the PowerShell module locally:
|
||||
```powershell
|
||||
Build.ps1
|
||||
Import-Module -Name '.\src\PSPetstore' -Verbose
|
||||
```
|
||||
|
||||
To avoid function name collision, one can use `-Prefix`, e.g. `Import-Module -Name '.\src\PSPetstore' -Prefix prefix`
|
||||
|
||||
To uninstall the module, simply run:
|
||||
```powershell
|
||||
Remove-Module -FullyQualifiedName @{ModuleName = "PSPetstore"; ModuleVersion = "0.1.2"}
|
||||
```
|
||||
|
||||
<a name="tests"></a>
|
||||
## Tests
|
||||
|
||||
To install and run `Pester`, please execute the following commands in the terminal:
|
||||
|
||||
```powershell
|
||||
Install-module -name Pester -force
|
||||
|
||||
Invoker-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://petstore.swagger.io:80/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*PSPetApi* | [**Add-PSPet**](docs/PSPetApi.md#Add-PSPet) | **POST** /pet | Add a new pet to the store
|
||||
*PSPetApi* | [**Remove-Pet**](docs/PSPetApi.md#remove-pet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
*PSPetApi* | [**Find-PSPetsByStatus**](docs/PSPetApi.md#Find-PSPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
*PSPetApi* | [**Find-PSPetsByTags**](docs/PSPetApi.md#Find-PSPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
*PSPetApi* | [**Get-PSPetById**](docs/PSPetApi.md#Get-PSPetById) | **GET** /pet/{petId} | Find pet by ID
|
||||
*PSPetApi* | [**Update-PSPet**](docs/PSPetApi.md#Update-PSPet) | **PUT** /pet | Update an existing pet
|
||||
*PSPetApi* | [**Update-PSPetWithForm**](docs/PSPetApi.md#Update-PSPetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
*PSPetApi* | [**Invoke-PSUploadFile**](docs/PSPetApi.md#Invoke-PSUploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
*PSStoreApi* | [**Remove-PSOrder**](docs/PSStoreApi.md#Remove-PSOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
||||
*PSStoreApi* | [**Get-PSInventory**](docs/PSStoreApi.md#Get-PSInventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
*PSStoreApi* | [**Get-PSOrderById**](docs/PSStoreApi.md#Get-PSOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
|
||||
*PSStoreApi* | [**Invoke-PSPlaceOrder**](docs/PSStoreApi.md#Invoke-PSPlaceOrder) | **POST** /store/order | Place an order for a pet
|
||||
*PSUserApi* | [**New-PSUser**](docs/PSUserApi.md#New-PSUser) | **POST** /user | Create user
|
||||
*PSUserApi* | [**New-PSUsersWithArrayInput**](docs/PSUserApi.md#New-PSUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
*PSUserApi* | [**New-PSUsersWithListInput**](docs/PSUserApi.md#New-PSUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
*PSUserApi* | [**Remove-PSUser**](docs/PSUserApi.md#Remove-PSUser) | **DELETE** /user/{username} | Delete user
|
||||
*PSUserApi* | [**Get-PSUserByName**](docs/PSUserApi.md#Get-PSUserByName) | **GET** /user/{username} | Get user by user name
|
||||
*PSUserApi* | [**Invoke-PSLoginUser**](docs/PSUserApi.md#Invoke-PSLoginUser) | **GET** /user/login | Logs user into the system
|
||||
*PSUserApi* | [**Invoke-PSLogoutUser**](docs/PSUserApi.md#Invoke-PSLogoutUser) | **GET** /user/logout | Logs out current logged in user session
|
||||
*PSUserApi* | [**Update-PSUser**](docs/PSUserApi.md#Update-PSUser) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
## Documentation for Models
|
||||
|
||||
- [PSPetstore/Model.ApiResponse](docs/ApiResponse.md)
|
||||
- [PSPetstore/Model.Category](docs/Category.md)
|
||||
- [PSPetstore/Model.InlineObject](docs/InlineObject.md)
|
||||
- [PSPetstore/Model.InlineObject1](docs/InlineObject1.md)
|
||||
- [PSPetstore/Model.Order](docs/Order.md)
|
||||
- [PSPetstore/Model.Pet](docs/Pet.md)
|
||||
- [PSPetstore/Model.Tag](docs/Tag.md)
|
||||
- [PSPetstore/Model.User](docs/User.md)
|
||||
|
||||
|
||||
## Documentation for Authorization
|
||||
|
||||
|
||||
### api_key
|
||||
|
||||
- **Type**: API key
|
||||
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
|
||||
### auth_cookie
|
||||
|
||||
- **Type**: API key
|
||||
|
||||
- **API key parameter name**: AUTH_KEY
|
||||
- **Location**:
|
||||
|
||||
|
||||
### petstore_auth
|
||||
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: implicit
|
||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||
- **Scopes**:
|
||||
- write:pets: modify pets in your account
|
||||
- read:pets: read your pets
|
||||
|
@ -1 +1 @@
|
||||
4.2.3-SNAPSHOT
|
||||
5.0.0-SNAPSHOT
|
@ -1,3 +1,10 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# Version: 1.0.0
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
function Get-FunctionsToExport {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
@ -38,51 +45,28 @@ function Get-FunctionsToExport {
|
||||
}
|
||||
|
||||
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
|
||||
$ClientPath = ("$ScriptDir\..\..\petstore\csharp\OpenAPIClient" | Resolve-Path).ProviderPath
|
||||
$FunctionPath = 'API', 'Model' | ForEach-Object {Join-Path "$ScriptDir\src\Org.OpenAPITools\" $_}
|
||||
$BinPath = "$ScriptDir\src\Org.OpenAPITools\Bin"
|
||||
|
||||
Start-Process -FilePath "$ClientPath\build.bat" -WorkingDirectory $ClientPath -Wait -NoNewWindow
|
||||
|
||||
if (!(Test-Path "$ScriptDir\src\Org.OpenAPITools\Bin" -PathType Container)) {
|
||||
New-Item "$ScriptDir\src\Org.OpenAPITools\Bin" -ItemType Directory > $null
|
||||
}
|
||||
|
||||
Copy-Item "$ClientPath\bin\*.dll" $BinPath
|
||||
$FunctionPath = 'Api', 'Model', 'Client' | ForEach-Object {Join-Path "$ScriptDir\src\PSPetstore\" $_}
|
||||
|
||||
$Manifest = @{
|
||||
Path = "$ScriptDir\src\Org.OpenAPITools\Org.OpenAPITools.psd1"
|
||||
Path = "$ScriptDir\src\PSPetstore\PSPetstore.psd1"
|
||||
|
||||
Author = 'OpenAPI Generator Team'
|
||||
CompanyName = 'openapitools.org'
|
||||
Description = 'Org.OpenAPITools - the PowerShell module for OpenAPI Petstore'
|
||||
Description = 'PSPetstore - the PowerShell module for OpenAPI Petstore'
|
||||
|
||||
RootModule = 'Org.OpenAPITools.psm1'
|
||||
ModuleVersion = '0.1.2'
|
||||
|
||||
RootModule = 'PSPetstore.psm1'
|
||||
Guid = 'a27b908d-2a20-467f-bc32-af6f3a654ac5' # Has to be static, otherwise each new build will be considered different module
|
||||
|
||||
PowerShellVersion = '3.0'
|
||||
|
||||
RequiredAssemblies = Get-ChildItem "$BinPath\*.dll" | ForEach-Object {
|
||||
Join-Path $_.Directory.Name $_.Name
|
||||
}
|
||||
|
||||
FunctionsToExport = $FunctionPath | Get-ChildItem -Filter *.ps1 | Get-FunctionsToExport
|
||||
|
||||
VariablesToExport = @()
|
||||
AliasesToExport = @()
|
||||
CmdletsToExport = @()
|
||||
|
||||
# Should we use prefix to prevent command name collisions?
|
||||
# https://www.sapien.com/blog/2016/02/15/use-prefixes-to-prevent-command-name-collision/
|
||||
#
|
||||
# Kirk Munro recommends against it:
|
||||
# https://www.sapien.com/blog/2016/02/15/use-prefixes-to-prevent-command-name-collision/#comment-20820
|
||||
#
|
||||
# If not, we'd need to generate functions name with prefix. For examples,
|
||||
#
|
||||
# DefaultCommandPrefix = 'PetApi'
|
||||
# DefaultCommandPrefix = 'StoreApi'
|
||||
# DefaultCommandPrefix = 'UserApi'
|
||||
}
|
||||
|
||||
New-ModuleManifest @Manifest
|
||||
|
@ -1,30 +1,120 @@
|
||||
# Org.OpenAPITools - the PowerShell module for the OpenAPI Petstore
|
||||
# PSPetstore - the PowerShell module for the OpenAPI Petstore
|
||||
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
This PowerShell module is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: 1.0.0
|
||||
- SDK version:
|
||||
- SDK version: 0.1.2
|
||||
- Build package: org.openapitools.codegen.languages.PowerShellClientCodegen
|
||||
|
||||
<a name="frameworks-supported"></a>
|
||||
## Frameworks supported
|
||||
- PowerShell 3.0 or later
|
||||
- PowerShell 5.0 or later
|
||||
|
||||
<a name="dependencies"></a>
|
||||
## Dependencies
|
||||
- C# API client generated by OpenAPI Generator AND should be located in $ScriptDir\..\..\petstore\csharp\OpenAPIClient as stated in Build.ps1
|
||||
|
||||
<a name="installation"></a>
|
||||
## Installation
|
||||
Run the following command to generate the DLL
|
||||
- [Windows] `Build.ps1`
|
||||
|
||||
Then import module from the .\src\Org.OpenAPITools folder:
|
||||
To install from PowerShell Gallery (https://www.powershellgallery.com/packages/PSPetstore)
|
||||
```powershell
|
||||
using Org.OpenAPITools.Org.OpenAPITools/API;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Org.OpenAPITools/Model;
|
||||
Import-Module -Name PSPetstore -Verbose
|
||||
```
|
||||
|
||||
To install from the source, run the following command to build and install the PowerShell module locally:
|
||||
```powershell
|
||||
Build.ps1
|
||||
Import-Module -Name '.\src\PSPetstore' -Verbose
|
||||
```
|
||||
|
||||
To avoid function name collision, one can use `-Prefix`, e.g. `Import-Module -Name '.\src\PSPetstore' -Prefix prefix`
|
||||
|
||||
To uninstall the module, simply run:
|
||||
```powershell
|
||||
Remove-Module -FullyQualifiedName @{ModuleName = "PSPetstore"; ModuleVersion = "0.1.2"}
|
||||
```
|
||||
|
||||
<a name="tests"></a>
|
||||
## Tests
|
||||
|
||||
To install and run `Pester`, please execute the following commands in the terminal:
|
||||
|
||||
```powershell
|
||||
Install-module -name Pester -force
|
||||
|
||||
Invoker-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://petstore.swagger.io:80/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*PSPetApi* | [**Add-PSPet**](docs/PSPetApi.md#Add-PSPet) | **POST** /pet | Add a new pet to the store
|
||||
*PSPetApi* | [**Remove-Pet**](docs/PSPetApi.md#remove-pet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
*PSPetApi* | [**Find-PSPetsByStatus**](docs/PSPetApi.md#Find-PSPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
*PSPetApi* | [**Find-PSPetsByTags**](docs/PSPetApi.md#Find-PSPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
*PSPetApi* | [**Get-PSPetById**](docs/PSPetApi.md#Get-PSPetById) | **GET** /pet/{petId} | Find pet by ID
|
||||
*PSPetApi* | [**Update-PSPet**](docs/PSPetApi.md#Update-PSPet) | **PUT** /pet | Update an existing pet
|
||||
*PSPetApi* | [**Update-PSPetWithForm**](docs/PSPetApi.md#Update-PSPetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
*PSPetApi* | [**Invoke-PSUploadFile**](docs/PSPetApi.md#Invoke-PSUploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
*PSStoreApi* | [**Remove-PSOrder**](docs/PSStoreApi.md#Remove-PSOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
||||
*PSStoreApi* | [**Get-PSInventory**](docs/PSStoreApi.md#Get-PSInventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
*PSStoreApi* | [**Get-PSOrderById**](docs/PSStoreApi.md#Get-PSOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
|
||||
*PSStoreApi* | [**Invoke-PSPlaceOrder**](docs/PSStoreApi.md#Invoke-PSPlaceOrder) | **POST** /store/order | Place an order for a pet
|
||||
*PSUserApi* | [**New-PSUser**](docs/PSUserApi.md#New-PSUser) | **POST** /user | Create user
|
||||
*PSUserApi* | [**New-PSUsersWithArrayInput**](docs/PSUserApi.md#New-PSUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
*PSUserApi* | [**New-PSUsersWithListInput**](docs/PSUserApi.md#New-PSUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
*PSUserApi* | [**Remove-PSUser**](docs/PSUserApi.md#Remove-PSUser) | **DELETE** /user/{username} | Delete user
|
||||
*PSUserApi* | [**Get-PSUserByName**](docs/PSUserApi.md#Get-PSUserByName) | **GET** /user/{username} | Get user by user name
|
||||
*PSUserApi* | [**Invoke-PSLoginUser**](docs/PSUserApi.md#Invoke-PSLoginUser) | **GET** /user/login | Logs user into the system
|
||||
*PSUserApi* | [**Invoke-PSLogoutUser**](docs/PSUserApi.md#Invoke-PSLogoutUser) | **GET** /user/logout | Logs out current logged in user session
|
||||
*PSUserApi* | [**Update-PSUser**](docs/PSUserApi.md#Update-PSUser) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
## Documentation for Models
|
||||
|
||||
- [PSPetstore/Model.ApiResponse](docs/ApiResponse.md)
|
||||
- [PSPetstore/Model.Category](docs/Category.md)
|
||||
- [PSPetstore/Model.InlineObject](docs/InlineObject.md)
|
||||
- [PSPetstore/Model.InlineObject1](docs/InlineObject1.md)
|
||||
- [PSPetstore/Model.Order](docs/Order.md)
|
||||
- [PSPetstore/Model.Pet](docs/Pet.md)
|
||||
- [PSPetstore/Model.Tag](docs/Tag.md)
|
||||
- [PSPetstore/Model.User](docs/User.md)
|
||||
|
||||
|
||||
## Documentation for Authorization
|
||||
|
||||
|
||||
### api_key
|
||||
|
||||
- **Type**: API key
|
||||
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
|
||||
### auth_cookie
|
||||
|
||||
- **Type**: API key
|
||||
|
||||
- **API key parameter name**: AUTH_KEY
|
||||
- **Location**:
|
||||
|
||||
|
||||
### petstore_auth
|
||||
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: implicit
|
||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||
- **Scopes**:
|
||||
- write:pets: modify pets in your account
|
||||
- read:pets: read your pets
|
||||
|
||||
|
Before Width: | Height: | Size: 59 B After Width: | Height: | Size: 59 B |
@ -1,164 +0,0 @@
|
||||
function Invoke-PetApiAddPet {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.Pet]
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: PetApi-AddPet' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:PetApi.AddPet(
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-PetApiDeletePet {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Int64]
|
||||
${petId},
|
||||
[Parameter(Position = 1, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
|
||||
[String]
|
||||
${apiKey}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: PetApi-DeletePet' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:PetApi.DeletePet(
|
||||
${petId},
|
||||
${apiKey}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-PetApiFindPetsByStatus {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[String[]]
|
||||
${status}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: PetApi-FindPetsByStatus' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:PetApi.FindPetsByStatus(
|
||||
${status}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-PetApiFindPetsByTags {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[String[]]
|
||||
${tags}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: PetApi-FindPetsByTags' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:PetApi.FindPetsByTags(
|
||||
${tags}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-PetApiGetPetById {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Int64]
|
||||
${petId}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: PetApi-GetPetById' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:PetApi.GetPetById(
|
||||
${petId}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-PetApiUpdatePet {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.Pet]
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: PetApi-UpdatePet' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:PetApi.UpdatePet(
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-PetApiUpdatePetWithForm {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Int64]
|
||||
${petId},
|
||||
[Parameter(Position = 1, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
|
||||
[String]
|
||||
${name},
|
||||
[Parameter(Position = 2, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
|
||||
[String]
|
||||
${status}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: PetApi-UpdatePetWithForm' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:PetApi.UpdatePetWithForm(
|
||||
${petId},
|
||||
${name},
|
||||
${status}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-PetApiUploadFile {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Int64]
|
||||
${petId},
|
||||
[Parameter(Position = 1, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
|
||||
[String]
|
||||
${additionalMetadata},
|
||||
[Parameter(Position = 2, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $false)]
|
||||
[String]
|
||||
${file}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: PetApi-UploadFile' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:PetApi.UploadFile(
|
||||
${petId},
|
||||
${additionalMetadata},
|
||||
${file}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,68 +0,0 @@
|
||||
function Invoke-StoreApiDeleteOrder {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[String]
|
||||
${orderId}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: StoreApi-DeleteOrder' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:StoreApi.DeleteOrder(
|
||||
${orderId}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-StoreApiGetInventory {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: StoreApi-GetInventory' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:StoreApi.GetInventory(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-StoreApiGetOrderById {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Int64]
|
||||
${orderId}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: StoreApi-GetOrderById' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:StoreApi.GetOrderById(
|
||||
${orderId}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-StoreApiPlaceOrder {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.Order]
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: StoreApi-PlaceOrder' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:StoreApi.PlaceOrder(
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,148 +0,0 @@
|
||||
function Invoke-UserApiCreateUser {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.User]
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: UserApi-CreateUser' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:UserApi.CreateUser(
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-UserApiCreateUsersWithArrayInput {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.User[]]
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: UserApi-CreateUsersWithArrayInput' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:UserApi.CreateUsersWithArrayInput(
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-UserApiCreateUsersWithListInput {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.User[]]
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: UserApi-CreateUsersWithListInput' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:UserApi.CreateUsersWithListInput(
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-UserApiDeleteUser {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[String]
|
||||
${username}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: UserApi-DeleteUser' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:UserApi.DeleteUser(
|
||||
${username}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-UserApiGetUserByName {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[String]
|
||||
${username}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: UserApi-GetUserByName' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:UserApi.GetUserByName(
|
||||
${username}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-UserApiLoginUser {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[String]
|
||||
${username},
|
||||
[Parameter(Position = 1, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[String]
|
||||
${password}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: UserApi-LoginUser' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:UserApi.LoginUser(
|
||||
${username},
|
||||
${password}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-UserApiLogoutUser {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: UserApi-LogoutUser' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:UserApi.LogoutUser(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-UserApiUpdateUser {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[String]
|
||||
${username},
|
||||
[Parameter(Position = 1, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[Org.OpenAPITools.Model.User]
|
||||
${body}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Calling method: UserApi-UpdateUser' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
$Script:UserApi.UpdateUser(
|
||||
${username},
|
||||
${body}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
function New-ApiResponse {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int32]]
|
||||
${code},
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${type},
|
||||
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${message}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Creating object: Org.OpenAPITools.Model.ApiResponse' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
New-Object -TypeName Org.OpenAPITools.Model.ApiResponse -ArgumentList @(
|
||||
${code},
|
||||
${type},
|
||||
${message}
|
||||
)
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
function New-Category {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int64]]
|
||||
${id},
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${name}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Creating object: Org.OpenAPITools.Model.Category' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
New-Object -TypeName Org.OpenAPITools.Model.Category -ArgumentList @(
|
||||
${id},
|
||||
${name}
|
||||
)
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
function New-InlineObject {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${name},
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${status}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Creating object: Org.OpenAPITools.Model.InlineObject' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
New-Object -TypeName Org.OpenAPITools.Model.InlineObject -ArgumentList @(
|
||||
${name},
|
||||
${status}
|
||||
)
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
function New-InlineObject1 {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${additionalMetadata},
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[String]]
|
||||
${file}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Creating object: Org.OpenAPITools.Model.InlineObject1' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
New-Object -TypeName Org.OpenAPITools.Model.InlineObject1 -ArgumentList @(
|
||||
${additionalMetadata},
|
||||
${file}
|
||||
)
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
function New-Order {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int64]]
|
||||
${id},
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int64]]
|
||||
${petId},
|
||||
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int32]]
|
||||
${quantity},
|
||||
[Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[System.DateTime]]
|
||||
${shipDate},
|
||||
[Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${status},
|
||||
[Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Boolean]]
|
||||
${complete}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Creating object: Org.OpenAPITools.Model.Order' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
New-Object -TypeName Org.OpenAPITools.Model.Order -ArgumentList @(
|
||||
${id},
|
||||
${petId},
|
||||
${quantity},
|
||||
${shipDate},
|
||||
${status},
|
||||
${complete}
|
||||
)
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
function New-Pet {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int64]]
|
||||
${id},
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[Org.OpenAPITools.Model.Category]
|
||||
${category},
|
||||
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[String]
|
||||
${name},
|
||||
[Parameter(Position = 3, ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
|
||||
[String[]]
|
||||
${photoUrls},
|
||||
[Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
|
||||
[Org.OpenAPITools.Model.Tag[]]
|
||||
${tags},
|
||||
[Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${status}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Creating object: Org.OpenAPITools.Model.Pet' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
New-Object -TypeName Org.OpenAPITools.Model.Pet -ArgumentList @(
|
||||
${id},
|
||||
${category},
|
||||
${name},
|
||||
${photoUrls},
|
||||
${tags},
|
||||
${status}
|
||||
)
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
function New-Tag {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int64]]
|
||||
${id},
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${name}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Creating object: Org.OpenAPITools.Model.Tag' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
New-Object -TypeName Org.OpenAPITools.Model.Tag -ArgumentList @(
|
||||
${id},
|
||||
${name}
|
||||
)
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
function New-User {
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int64]]
|
||||
${id},
|
||||
[Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${username},
|
||||
[Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${firstName},
|
||||
[Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${lastName},
|
||||
[Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${email},
|
||||
[Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${password},
|
||||
[Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
|
||||
[String]
|
||||
${phone},
|
||||
[Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)]
|
||||
[System.Nullable[Int32]]
|
||||
${userStatus}
|
||||
)
|
||||
|
||||
Process {
|
||||
'Creating object: Org.OpenAPITools.Model.User' | Write-Verbose
|
||||
$PSBoundParameters | Out-DebugParameter | Write-Debug
|
||||
|
||||
New-Object -TypeName Org.OpenAPITools.Model.User -ArgumentList @(
|
||||
${id},
|
||||
${username},
|
||||
${firstName},
|
||||
${lastName},
|
||||
${email},
|
||||
${password},
|
||||
${phone},
|
||||
${userStatus}
|
||||
)
|
||||
}
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
#
|
||||
# Module manifest for module 'Org.OpenAPITools'
|
||||
#
|
||||
# Generated by: OpenAPI Generator Team
|
||||
#
|
||||
# Generated on: 3/29/20
|
||||
#
|
||||
|
||||
@{
|
||||
|
||||
# Script module or binary module file associated with this manifest.
|
||||
RootModule = 'Org.OpenAPITools.psm1'
|
||||
|
||||
# Version number of this module.
|
||||
ModuleVersion = '0.0.1'
|
||||
|
||||
# Supported PSEditions
|
||||
# CompatiblePSEditions = @()
|
||||
|
||||
# ID used to uniquely identify this module
|
||||
GUID = 'a27b908d-2a20-467f-bc32-af6f3a654ac5'
|
||||
|
||||
# Author of this module
|
||||
Author = 'OpenAPI Generator Team'
|
||||
|
||||
# Company or vendor of this module
|
||||
CompanyName = 'openapitools.org'
|
||||
|
||||
# Copyright statement for this module
|
||||
Copyright = '(c) OpenAPI Generator Team. All rights reserved.'
|
||||
|
||||
# Description of the functionality provided by this module
|
||||
Description = 'Org.OpenAPITools - the PowerShell module for OpenAPI Petstore'
|
||||
|
||||
# Minimum version of the PowerShell engine required by this module
|
||||
PowerShellVersion = '3.0'
|
||||
|
||||
# Name of the PowerShell host required by this module
|
||||
# PowerShellHostName = ''
|
||||
|
||||
# Minimum version of the PowerShell host required by this module
|
||||
# PowerShellHostVersion = ''
|
||||
|
||||
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
|
||||
# DotNetFrameworkVersion = ''
|
||||
|
||||
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
|
||||
# CLRVersion = ''
|
||||
|
||||
# Processor architecture (None, X86, Amd64) required by this module
|
||||
# ProcessorArchitecture = ''
|
||||
|
||||
# Modules that must be imported into the global environment prior to importing this module
|
||||
# RequiredModules = @()
|
||||
|
||||
# Assemblies that must be loaded prior to importing this module
|
||||
# RequiredAssemblies = @()
|
||||
|
||||
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
|
||||
# ScriptsToProcess = @()
|
||||
|
||||
# Type files (.ps1xml) to be loaded when importing this module
|
||||
# TypesToProcess = @()
|
||||
|
||||
# Format files (.ps1xml) to be loaded when importing this module
|
||||
# FormatsToProcess = @()
|
||||
|
||||
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
|
||||
# NestedModules = @()
|
||||
|
||||
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
|
||||
FunctionsToExport = 'Invoke-PetApiAddPet', 'Invoke-PetApiDeletePet',
|
||||
'Invoke-PetApiFindPetsByStatus', 'Invoke-PetApiFindPetsByTags',
|
||||
'Invoke-PetApiGetPetById', 'Invoke-PetApiUpdatePet',
|
||||
'Invoke-PetApiUpdatePetWithForm', 'Invoke-PetApiUploadFile',
|
||||
'Invoke-StoreApiDeleteOrder', 'Invoke-StoreApiGetInventory',
|
||||
'Invoke-StoreApiGetOrderById', 'Invoke-StoreApiPlaceOrder',
|
||||
'Invoke-UserApiCreateUser',
|
||||
'Invoke-UserApiCreateUsersWithArrayInput',
|
||||
'Invoke-UserApiCreateUsersWithListInput',
|
||||
'Invoke-UserApiDeleteUser', 'Invoke-UserApiGetUserByName',
|
||||
'Invoke-UserApiLoginUser', 'Invoke-UserApiLogoutUser',
|
||||
'Invoke-UserApiUpdateUser', 'New-ApiResponse', 'New-Category',
|
||||
'New-InlineObject', 'New-InlineObject1', 'New-Order', 'New-Pet',
|
||||
'New-Tag', 'New-User'
|
||||
|
||||
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
|
||||
CmdletsToExport = @()
|
||||
|
||||
# Variables to export from this module
|
||||
# VariablesToExport = @()
|
||||
|
||||
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
|
||||
AliasesToExport = @()
|
||||
|
||||
# DSC resources to export from this module
|
||||
# DscResourcesToExport = @()
|
||||
|
||||
# List of all modules packaged with this module
|
||||
# ModuleList = @()
|
||||
|
||||
# List of all files packaged with this module
|
||||
# FileList = @()
|
||||
|
||||
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
|
||||
PrivateData = @{
|
||||
|
||||
PSData = @{
|
||||
|
||||
# Tags applied to this module. These help with module discovery in online galleries.
|
||||
# Tags = @()
|
||||
|
||||
# A URL to the license for this module.
|
||||
# LicenseUri = ''
|
||||
|
||||
# A URL to the main website for this project.
|
||||
# ProjectUri = ''
|
||||
|
||||
# A URL to an icon representing this module.
|
||||
# IconUri = ''
|
||||
|
||||
# ReleaseNotes of this module
|
||||
# ReleaseNotes = ''
|
||||
|
||||
} # End of PSData hashtable
|
||||
|
||||
} # End of PrivateData hashtable
|
||||
|
||||
# HelpInfo URI of this module
|
||||
# HelpInfoURI = ''
|
||||
|
||||
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
|
||||
# DefaultCommandPrefix = ''
|
||||
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
#region Import functions
|
||||
|
||||
'API', 'Model', 'Private' | Get-ChildItem -Path {
|
||||
Join-Path $PSScriptRoot $_
|
||||
} -Filter '*.ps1' | ForEach-Object {
|
||||
Write-Verbose "Importing file: $($_.BaseName)"
|
||||
try {
|
||||
. $_.FullName
|
||||
} catch {
|
||||
Write-Verbose "Can't import function!"
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Initialize APIs
|
||||
|
||||
'Creating object: Org.OpenAPITools.Api.PetApi' | Write-Verbose
|
||||
$Script:PetApi= New-Object -TypeName Org.OpenAPITools.Api.PetApi -ArgumentList @($null)
|
||||
|
||||
'Creating object: Org.OpenAPITools.Api.StoreApi' | Write-Verbose
|
||||
$Script:StoreApi= New-Object -TypeName Org.OpenAPITools.Api.StoreApi -ArgumentList @($null)
|
||||
|
||||
'Creating object: Org.OpenAPITools.Api.UserApi' | Write-Verbose
|
||||
$Script:UserApi= New-Object -TypeName Org.OpenAPITools.Api.UserApi -ArgumentList @($null)
|
||||
|
||||
|
||||
#endregion
|
@ -1,14 +0,0 @@
|
||||
<#
|
||||
.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
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<#
|
||||
.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()) {
|
||||
$_
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
PSTOPIC
|
||||
about_Org.OpenAPITools
|
||||
|
||||
SHORT DESCRIPTION
|
||||
Org.OpenAPITools - the PowerShell module for the OpenAPI Petstore
|
||||
|
||||
LONG DESCRIPTION
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
This PowerShell module is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: 1.0.0
|
||||
- SDK version:
|
||||
- Build package: org.openapitools.codegen.languages.PowerShellClientCodegen
|
||||
|
||||
Frameworks supported:
|
||||
|
||||
* PowerShell 3.0+
|
||||
* .NET 4.0 or later
|
@ -95,6 +95,21 @@ function Invoke-PSApiClient {
|
||||
$RequestBody = $Body
|
||||
}
|
||||
|
||||
# http signature authentication
|
||||
if ($null -ne $Configuration['ApiKey'] -and $Configuration['ApiKey'].Count -gt 0) {
|
||||
$httpSignHeaderArgument = @{
|
||||
Method = $Method
|
||||
UriBuilder = $UriBuilder
|
||||
Body = $Body
|
||||
}
|
||||
$signedHeader = Get-PSHttpSignedHeader @httpSignHeaderArgument
|
||||
if($null -ne $signedHeader -and $signedHeader.Count -gt 0){
|
||||
foreach($item in $signedHeader.GetEnumerator()){
|
||||
$HeaderParameters[$item.Name] = $item.Value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($SkipCertificateCheck -eq $true) {
|
||||
$Response = Invoke-WebRequest -Uri $UriBuilder.Uri `
|
||||
-Method $Method `
|
@ -11,7 +11,7 @@ LONG DESCRIPTION
|
||||
|
||||
- API version: 1.0.0
|
||||
- SDK version: 0.1.2
|
||||
- Build package: org.openapitools.codegen.languages.PowerShellExperimentalClientCodegen
|
||||
- Build package: org.openapitools.codegen.languages.PowerShellClientCodegen
|
||||
|
||||
Frameworks supported:
|
||||
|
@ -1,2 +0,0 @@
|
||||
## TODO we need to update the template to test the model files
|
||||
|
@ -1,2 +0,0 @@
|
||||
## TODO we need to update the template to test the model files
|
||||
|
@ -1,2 +0,0 @@
|
||||
## TODO we need to update the template to test the model files
|
||||
|
@ -1,2 +0,0 @@
|
||||
## TODO we need to update the template to test the model files
|
||||
|
@ -1,2 +0,0 @@
|
||||
## TODO we need to update the template to test the model files
|
||||
|
@ -1,69 +0,0 @@
|
||||
# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
# Please replace "TEST_VALUE" with a proper value and uncomment the code for testing the function
|
||||
|
||||
Describe 'Org.OpenAPITools PetApi' {
|
||||
Context 'PetApi' {
|
||||
It 'Invoke-PetApiAddPet' {
|
||||
$ret = Invoke-PetApiGetPetById -pet "TEST_VALUE"
|
||||
#$ret | Should BeOfType Org.OpenAPITools.Model.ModelNameHere
|
||||
#$ret.property | Should Be 0
|
||||
}
|
||||
}
|
||||
|
||||
Context 'PetApi' {
|
||||
It 'Invoke-PetApiDeletePet' {
|
||||
$ret = Invoke-PetApiGetPetById -petId "TEST_VALUE" -apiKey "TEST_VALUE"
|
||||
#$ret | Should BeOfType Org.OpenAPITools.Model.ModelNameHere
|
||||
#$ret.property | Should Be 0
|
||||
}
|
||||
}
|
||||
|
||||
Context 'PetApi' {
|
||||
It 'Invoke-PetApiFindPetsByStatus' {
|
||||
$ret = Invoke-PetApiGetPetById -status "TEST_VALUE"
|
||||
#$ret | Should BeOfType Org.OpenAPITools.Model.ModelNameHere
|
||||
#$ret.property | Should Be 0
|
||||
}
|
||||
}
|
||||
|
||||
Context 'PetApi' {
|
||||
It 'Invoke-PetApiFindPetsByTags' {
|
||||
$ret = Invoke-PetApiGetPetById -tags "TEST_VALUE"
|
||||
#$ret | Should BeOfType Org.OpenAPITools.Model.ModelNameHere
|
||||
#$ret.property | Should Be 0
|
||||
}
|
||||
}
|
||||
|
||||
Context 'PetApi' {
|
||||
It 'Invoke-PetApiGetPetById' {
|
||||
$ret = Invoke-PetApiGetPetById -petId "TEST_VALUE"
|
||||
#$ret | Should BeOfType Org.OpenAPITools.Model.ModelNameHere
|
||||
#$ret.property | Should Be 0
|
||||
}
|
||||
}
|
||||
|
||||
Context 'PetApi' {
|
||||
It 'Invoke-PetApiUpdatePet' {
|
||||
$ret = Invoke-PetApiGetPetById -pet "TEST_VALUE"
|
||||
#$ret | Should BeOfType Org.OpenAPITools.Model.ModelNameHere
|
||||
#$ret.property | Should Be 0
|
||||
}
|
||||
}
|
||||
|
||||
Context 'PetApi' {
|
||||
It 'Invoke-PetApiUpdatePetWithForm' {
|
||||
$ret = Invoke-PetApiGetPetById -petId "TEST_VALUE" -name "TEST_VALUE" -status "TEST_VALUE"
|
||||
#$ret | Should BeOfType Org.OpenAPITools.Model.ModelNameHere
|
||||
#$ret.property | Should Be 0
|
||||
}
|
||||
}
|
||||
|
||||
Context 'PetApi' {
|
||||
It 'Invoke-PetApiUploadFile' {
|
||||
$ret = Invoke-PetApiGetPetById -petId "TEST_VALUE" -additionalMetadata "TEST_VALUE" -file "TEST_VALUE"
|
||||
#$ret | Should BeOfType Org.OpenAPITools.Model.ModelNameHere
|
||||
#$ret.property | Should Be 0
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user