forked from ErikWittern/openapi-snippet
-
Notifications
You must be signed in to change notification settings - Fork 2
Merge ErikWittern/openapi-snippet #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
* Add x-www-form-urlencoded media type * ditch querystring dependency * escape keys and values * add test * fix: replace all '%20' occurrences * fix: use replace function with wildcard instead of replaceAll * improve syntax Co-authored-by: Diogo Silva <diogo.silva@alviere.com>
* Update query string parsing to look for parameters defined on the path in addition to the method. * Add return to method comment block * Fix comment formatting * Add tests to verify that method params override path params. Update query strings so method params override path params * Format all code
* Add support for multipart/form-data snippet generation. Add tests to verify behavior * Add functionality to generate multiple snippets for an endpoint method if there are multiple content-type request bodies. Refactor generation methods to adjust for return type changes. Refactor header parsing to move content-type header to come from the postData parsing * Set mimeType to contentType instead of using magic string * Don't copy sample * Fix formatting * DRY payloads method up a bit * Move snippet creation into its own function. Only set mimeType if har.comment is undefined, not set to undefined. Fix some formatting * run prettier on code
Form data must be of type string, so stringify objects and arrays
* Revise example swagger to match test There are three test cases dealing with array value query parameters in test/parameter_example_swagger.json. The assertion for each of these is wrong as it assumes the array should not be exploded. However, two of these parameters are explicitly form style. The third is implicitly form style because that is the default for query parameters. None of them specify a value for explode, so this defaults to true. Therefore the assertions are wrong. See https://spec.openapis.org/oas/v3.0.3#fixed-fields-9 This commit does not fix the logic in the code, rather (for now) it just updates the spec that is being used for the test to set explode equal to false. * create function createHarParameterObjects This function takes an OpenAPI parameter and a sample value and creates a HAR "parameter" object which is just a {name: "", value: ""} object. The function handles all of the variatons outlined in the spec and this commit adds all the test cases that are presented here: https://swagger.io/docs/specification/serialization This function will be used in future commits to handle every type of parrameter while generating snippets. * refactor getParameterValues in terms of createHarParameterObjects This doesn't change the functionality yet. This is just in preparation for providing full support for all variations of parameters. This commit breaks no tests but prepares us for more test cases. * Add support for exploded values in query parameters * Add support for simple style exploded values in path * Add tests to demonstrate working label style path params * Add tests to demonstrate working matrix style path params * Add support for pipe and space delimited path params * Add tests to demonstrate working object and array values in headers * Re-order checks for candidate example param values Per the swagger guide: https://swagger.io/docs/specification/describing-parameters/ "Using default to specify a sample value. This is not intended use of default and can lead to unexpected behavior in some Swagger tools. Use the example or examples keyword for this purpose instead." Per this I think `default` should be the sample value of last resort instead favoring `example` and `examples` first. * Add support for samples in examples key This works for header, path, and query parameter which will now be discovered if the sample is in the examles key. The snippet will choose the first example in examples. * refactor getQueryStrings in terms of reusable method getQueryStrings was doing something special that getFullPath and getHeadersArray are not doing: considering both path and operation level defined parameters. By parameterizing this method on `in` we can later use it for `path`, `header` and `cookie` parameters as well. * Refactor getFullPath and getHeadersArray These functions are now written in terms of getParameterCollectionIn which does the following correctly * Considers path and operation parameters and overrides appropriately * Resolves parameter references * Resolves schema references * Looks at example, examples, schema.example and default keys looking for sample value So now getFullPath and getHeadersArray benefit from all of this logic. Each had one or more short comings. * Add support for cookie parameters * Resolve examples objects as needed
Bumps [shell-quote](https://github.com/substack/node-shell-quote) from 1.7.2 to 1.7.3. - [Release notes](https://github.com/substack/node-shell-quote/releases) - [Changelog](https://github.com/substack/node-shell-quote/blob/master/CHANGELOG.md) - [Commits](https://github.com/substack/node-shell-quote/compare/v1.7.2...1.7.3) --- updated-dependencies: - dependency-name: shell-quote dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [cached-path-relative](https://github.com/ashaffer/cached-path-relative) from 1.0.2 to 1.1.0. - [Release notes](https://github.com/ashaffer/cached-path-relative/releases) - [Commits](https://github.com/ashaffer/cached-path-relative/commits) --- updated-dependencies: - dependency-name: cached-path-relative dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.12.0 to 6.12.6. - [Release notes](https://github.com/ajv-validator/ajv/releases) - [Commits](ajv-validator/ajv@v6.12.0...v6.12.6) --- updated-dependencies: - dependency-name: ajv dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
❌ Error getting contributor login(s). |
QifanWuCFLT
approved these changes
Jan 15, 2025
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.
No description provided.