Fix proxy type - #18166
Merged
Merged
Conversation
Fix check of proxy type
Member
|
PS tests passed via https://ci.appveyor.com/project/WilliamCheng/openapi-generator/builds/49441588 thanks for the PR, let's give it a try |
zapodot
pushed a commit
to zapodot/openapi-generator
that referenced
this pull request
Mar 21, 2024
* Update configuration.mustache Fix check of proxy type * Changing sample source files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[PowerShell] Fix proxy type (@wing328)
The file
configuration.mustacheinmodules/openapi-generator/src/main/resources/powershell/configuration.mustachecontains the following check in the functionSet-{{{apiNamePrefix}}}ConfigurationThe check fails in multiple environments, either because the type checked is unknown, or because the class returned by
GetSystemWebProxy()is different from what is expected.$PSVersionTableName Value ---- ----- PSVersion 5.1.19041.4046 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.4046 [...]Name Value ---- ----- PSVersion 7.4.1 PSEdition Core GitCommitId 7.4.1 OS Microsoft Windows 10.0.19045 Platform Win32NT [...]Name Value ---- ----- PSVersion 7.4.1 PSEdition Core GitCommitId 7.4.1 OS Darwin 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:31 PST 2024; root:xnu-1006… Platform Unix [...][System.Net.SystemWebProxy]$aUnable to find type [System.Net.SystemWebProxy]. At line:1 char:2 + [System.Net.SystemWebProxy]$a + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.SystemWebProxy:TypeName) [], RuntimeException + FullyQualifiedErrorId : TypeNotFoundInvalidOperation: Unable to find type [System.Net.SystemWebProxy].InvalidOperation: Unable to find type [System.Net.SystemWebProxy].([System.Net.WebRequest]:: GetSystemWebProxy()).GetType()IsPublic IsSerial Name BaseType -------- -------- ---- -------- False False WebProxyWrapperOpaque System.ObjectIsPublic IsSerial Name BaseType -------- -------- ---- -------- False False HttpWindowsProxy System.ObjectIsPublic IsSerial Name BaseType -------- -------- ---- -------- False False MacProxy System.ObjectSince all returned types implement (and by the available doc, shall implement) the interface
IWebProxy, I propose to replace the above test withThe change does not guarantee that the configured proxy will work on all systems (e.g. on Linux the default class is HttpNoProxy, and on MacOS proxy credentials are likely not yet implemented). Yet, when using the command
the request and response are intercepted as requested in the proxy, and can be used for debugging.
The test can be made by using e.g. Burp Suite Community Edition, enabling the proxy on 127.0.0.1:8080 and using the line above to configure the PowerShell PetStore client API.
PR checklist
Commit all changed files.
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*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)