Skip to content

CUT-5162: Inject x-powershell-method-name#100

Merged
gweinjc merged 5 commits into
CUT-5130_OpenAPIGeneratorfrom
CUT-5162_AddOASMethodName
May 29, 2026
Merged

CUT-5162: Inject x-powershell-method-name#100
gweinjc merged 5 commits into
CUT-5130_OpenAPIGeneratorfrom
CUT-5162_AddOASMethodName

Conversation

@gweinjc
Copy link
Copy Markdown
Contributor

@gweinjc gweinjc commented May 29, 2026

Issues

  • CUT-5162 - Inject x-powershell-method-name

What does this solve?

Created Add-OasMethodName

  • Functions purpose is to set a given operationID's function name that is defined in the mapping.json by injecting the x-powershell-method-name header into the OAS under that operationID.

Is there anything particularly tricky?

With the recent combination of the V1 and V2 endpoints into a singular OAS, I had to rework the mapping generation process due to the size of the OAS.

Also adjusted the docker script to remove the java requirement and openapi-generator requirement as they're redundant.

How should this be tested?

  1. Delete any .json files located in the /OpenAPI/OAS directory
    a. Example: JumpCloud.SDK.DirectoryInsights.json
  2. Get the latest JumpCloud.SDK.DirectoryInsights.json file from the private URL (https://docs.internal.jumpcloud.io/new/external/api/insights/directory/index.html)
  3. New Mapping Generation
# CD into the Scripts folder
cd '/Users/USERNAME/Documents/GitHub/jcapi-powershell/OpenAPI/scripts' 

# Import the function(s)
. '/Users/USERNAME/Documents/GitHub/jcapi-powershell/OpenAPI/scripts/OASFunctions.ps1'

# Run the function
Update-OasMapping
  1. Find the OpenAPI/OAS/mapping/OASMapping.DirectoryInsights.json
  2. Add values to the x-powershell-method-name property for each of the OperationIDs (They can be placeholders for testing). Example:
"directoryInsights_eventsCountPost": {
    "paginate": false,
    "method": "post",
    "x-powershell-method-name": "Get-JcSdkEventCount",
    "path": "/events/count"
  }
  1. Run the Add-OasMethodName function
Add-OasMethodName -SdkName 'DirectoryInsights'
  1. Open the OpenAPI/OAS/JumpCloud.SDK.DirectoryInsights.json and validate that the x-powershell-method-name was added for each of the operationIDs that you specified

Screenshots


Note

Low Risk
Changes affect OpenAPI/SDK build scripts and generated spec metadata only, not runtime API or security behavior.

Overview
This PR extends the OpenAPI → PowerShell SDK pipeline so each operation can carry a stable cmdlet name via the x-powershell-method-name extension.

Add-OasMethodName reads per-SDK OASMapping.*.json files and writes (or updates) that extension on the matching path/method in JumpCloud.SDK.*.json, keyed by operationId. Update-OasMapping was adjusted to build and merge mapping entries at scale—needed after V1 and V2 were combined into larger single specs— including placeholder x-powershell-method-name values on new operations.

Supporting changes include Docker/build script simplification (dropping redundant Java and openapi-generator steps) and a temporary OpenAPI/.gitignore entry for /PowerShell/* while OAS manipulation scripts are developed locally.

Reviewed by Cursor Bugbot for commit 20822f5. Bugbot is set up for automated code reviews on this repo. Configure here.

@gweinjc gweinjc requested a review from jworkmanjc May 29, 2026 15:40
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit ba9b91b. Configure here.

Comment thread OpenAPI/.gitignore
@@ -0,0 +1,2 @@
# Temp ignore on PowerShell folder while building OAS Manipulation Scripts
/PowerShell/* No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary gitignore risks permanently hiding generated SDK output

Medium Severity

The comment explicitly says "Temp ignore" but this is being merged into the main branch. The /PowerShell/* pattern will prevent any newly generated SDK files under OpenAPI/PowerShell/ from being tracked by git. The readme.md and generate-powershell-docker.mjs both show this directory is the intended output location for generated SDKs. If this .gitignore is forgotten, future SDK regeneration output will silently go untracked.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ba9b91b. Configure here.

@gweinjc gweinjc changed the base branch from master to CUT-5130_OpenAPIGenerator May 29, 2026 15:47
@junioralmeida-82 junioralmeida-82 self-requested a review May 29, 2026 18:40
@edgar-lins edgar-lins requested review from edgar-lins and removed request for edgar-lins May 29, 2026 18:41
Copy link
Copy Markdown

@edgar-lins edgar-lins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested following the steps in the description on the DirectoryInsights SDK:

  • Regenerated the mapping with Update-OasMapping
  • Set x-powershell-method-name for 3 operationIDs (placeholders), left the other 4 empty
  • Ran Add-OasMethodName -SdkName 'DirectoryInsights'

The 3 populated names were correctly injected into JumpCloud.SDK.DirectoryInsights.json at the right operationIDs. Works as expected for the main use case.

One observation: the function also injects the header for entries with an empty x-powershell-method-name, so the 4 empty ones ended up as "x-powershell-method-name": "" in the OAS spec. The comparison on the insertion check is just -ne against the existing value, so it doesn't skip empty entries.

Is that intentional? Does the SDK generator handle an empty x-powershell-method-name gracefully (fall back to the default name), or would it be cleaner to skip empty entries here? Not blocking — approving — just want to confirm the expected behavior downstream.

@gweinjc
Copy link
Copy Markdown
Contributor Author

gweinjc commented May 29, 2026

Tested following the steps in the description on the DirectoryInsights SDK:

  • Regenerated the mapping with Update-OasMapping
  • Set x-powershell-method-name for 3 operationIDs (placeholders), left the other 4 empty
  • Ran Add-OasMethodName -SdkName 'DirectoryInsights'

The 3 populated names were correctly injected into JumpCloud.SDK.DirectoryInsights.json at the right operationIDs. Works as expected for the main use case.

One observation: the function also injects the header for entries with an empty x-powershell-method-name, so the 4 empty ones ended up as "x-powershell-method-name": "" in the OAS spec. The comparison on the insertion check is just -ne against the existing value, so it doesn't skip empty entries.

Is that intentional? Does the SDK generator handle an empty x-powershell-method-name gracefully (fall back to the default name), or would it be cleaner to skip empty entries here? Not blocking — approving — just want to confirm the expected behavior downstream.

Yes this is intentional. The x-powershell-method-name will never be blank in the mapping file. We're going to have a CI test to validate that all of them are filled when making pull requests in the future

@lucasmendes-jc lucasmendes-jc self-requested a review May 29, 2026 19:30
@gweinjc gweinjc merged commit d9f6071 into CUT-5130_OpenAPIGenerator May 29, 2026
17 of 18 checks passed
@gweinjc gweinjc deleted the CUT-5162_AddOASMethodName branch May 29, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants