Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !8252

Implement optional powershell verb parsing

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/EngineerCoding/8233-optional-powershell-verb-parsing into master 4 years ago
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 2

Created by: EngineerCoding

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@wing328

To close #8233 (closed)

Compare
  • master (base)

and
  • latest version
    46d60ca8
    2 commits, 2 years ago

2 files
+ 26
- 13

    Preferences

    File browser
    Compare changes
docs/ge‎nerators‎
powers‎hell.md‎ +1 -0
modules/…/…/…/…‎/…/…/…/languages‎
PowerShellClie‎ntCodegen.java‎ +25 -13
docs/generators/powershell.md
+ 1
- 0
  • View file @ 46d60ca8

  • Edit in single-file editor

  • Open in Web IDE


@@ -19,6 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|powershellGalleryUrl|URL to the module in PowerShell Gallery (e.g. https://www.powershellgallery.com/packages/PSTwitter/).| |null|
|projectUri|A URL to the main website for this project| |null|
|releaseNotes|Release notes of the generated PowerShell module| |null|
|skipVerbParsing|Set skipVerbParsing to not try get powershell verbs of operation names| |null|
|tags|Tags applied to the generated PowerShell module. These help with module discovery in online galleries| |null|
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and onlye one match in oneOf's schemas) will be skipped.| |null|
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java
+ 25
- 13
  • View file @ 46d60ca8

  • Edit in single-file editor

  • Open in Web IDE


@@ -55,6 +55,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
protected HashSet methodNames; // store a list of method names to detect duplicates
protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
protected boolean discardReadOnly = false; // Discard the readonly property in initialize cmdlet
protected boolean skipVerbParsing = false; // Attempt to parse cmdlets from operation names
protected String projectUri;
protected String licenseUri;
protected String releaseNotes;
@@ -511,6 +512,8 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
cliOptions.add(new CliOption("licenseUri","A URL to the license for the generated PowerShell module"));
cliOptions.add(new CliOption("iconUri","A URL to an icon representing the generated PowerShell module"));
cliOptions.add(new CliOption("releaseNotes","Release notes of the generated PowerShell module"));
cliOptions.add(new CliOption("skipVerbParsing", "Set skipVerbParsing to not try get powershell verbs of operation names"));
// option to change how we process + set the data in the 'additionalProperties' keyword.
CliOption disallowAdditionalPropertiesIfNotPresentOpt = CliOption.newBoolean(
CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT,
@@ -601,6 +604,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
this.iconUri = iconUri;
}
public void setSkipVerbParsing(boolean skipVerbParsing) { this.skipVerbParsing = skipVerbParsing; };
@Override
public void processOpts() {
@@ -628,7 +632,13 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
setDiscardReadOnly(convertPropertyToBooleanAndWriteBack("discardReadOnly"));
} else {
additionalProperties.put("discardReadOnly", discardReadOnly);
}
}
if (additionalProperties.containsKey("skipVerbParsing")) {
setSkipVerbParsing(convertPropertyToBoolean("skipVerbParsing"));
} else {
additionalProperties.put("skipVerbParsing", skipVerbParsing);
}
if (additionalProperties.containsKey("tags")) {
String[] entries = ((String) additionalProperties.get("tags")).split(",");
@@ -1212,20 +1222,22 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
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;
if (!skipVerbParsing) {
// 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;
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;
}
}
}
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
2
Client: PowerShell Enhancement: Feature
2
Client: PowerShell Enhancement: Feature
    Assign labels
  • Manage project labels

Milestone
5.0.1
5.0.1 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
2
2 participants
Administrator
William Cheng
Reference: OpenAPITools/openapi-generator!8252
Source branch: github/fork/EngineerCoding/8233-optional-powershell-verb-parsing

Menu

Explore Projects Groups Snippets