Skip to content

[Oct-13-2022] Sync up with the head commit on erikwittern repo main branch #7

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

Closed

Conversation

TaihengJin
Copy link
Member

mainly picking up this change ErikWittern#67

codyaray and others added 30 commits February 26, 2020 01:47
Add support for type: http and schema basic or bearer in paths
Fixing support for schema references in parameters.
Fix assignment to constant in index.js
Signed-off-by: Erik-Wittern <erik.wittern@ibm.com>
OpenAPI 3.0 securityschemes fix for oauth2
OpenAPI 3.0 securitySchemes fix for oauth2
Replace path parameters with example values
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](indutny/elliptic@v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <support@github.com>
Add support for $ref in requestBody
Consider parameters inside methods too
…h-4.17.19

Bump lodash from 4.17.15 to 4.17.19
…tic-6.5.3

Bump elliptic from 6.5.2 to 6.5.3
"library" in L154 was declared as const, and possibly reassigned at L164 which resulted in a TypeError
Replace constant declaration for variable with let
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.3 to 6.5.4.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](indutny/elliptic@v6.5.3...v6.5.4)

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.19...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [json-pointer](https://github.com/manuelstofer/json-pointer) from 0.6.0 to 0.6.1.
- [Release notes](https://github.com/manuelstofer/json-pointer/releases)
- [Commits](https://github.com/manuelstofer/json-pointer/commits)

Signed-off-by: dependabot[bot] <support@github.com>
ErikWittern and others added 23 commits May 17, 2021 13:27
Add support for server overrides
…tic-6.5.4

Bump elliptic from 6.5.3 to 6.5.4
…h-4.17.21

Bump lodash from 4.17.19 to 4.17.21
…pointer-0.6.1

Bump json-pointer from 0.6.0 to 0.6.1
Add Support for using example field in parameter to generate snippet …
* 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>
@TaihengJin TaihengJin changed the title [Oct-13-2022] Sync up to the head commit of erikwittern repo main branch [Oct-13-2022] Sync up with the head commit on erikwittern repo main branch Oct 13, 2022
@TaihengJin TaihengJin closed this Oct 14, 2022
@TaihengJin TaihengJin reopened this Oct 14, 2022
@brianstrauch
Copy link
Member

Closed in favor of #13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.