This repository was archived by the owner on Aug 4, 2023. It is now read-only.
Deeper defaults for parameters in body#308
Open
farrago wants to merge 1 commit intoapigee-127:masterfrom
Open
Conversation
Body parameters (`in` is `"body"`) are always grouped in a single Object, and as such there is only the option to set a `default` for the whole body (or none). This change looks deeper into the object for `default`s to support more flexible configuration of expected parameters in `body`. This brings the body support closer to e.g. `path` which already supports multiple parameters. This change will look for defaults parameter values for all `object` type parameters. This is also recursive, so if an `object` has a parameter that is an `object` then this code will look for defaults in that nested object. Note: this has only been implemented for Swagger 2.0 as I am not familiar with Swagger 1.2, so felt it best to leave 1.2 as-is. Test Plan: - Test that `gulp` runs and passes, ensuring: -- new code passes lint rules -- existing unit tests all run and pass - Add new tests for testing the new features, and confirm all pass. - Check the code coverage, and verify that (almost) all new lines have been covered. -- The only new lines not being covered is the exclusion of Swagger 1.2 schemas, which has only been checked visually.
|
@whitlockjc Any chance this could be merged in? Seems to fix default body values as mentioned in #421 |
Member
|
I'll merge it in when I am planning the next release. That should be soon. |
|
@whitlockjc this is still an issue - do you intend to merge this or is there another way you want to do it? |
|
We're stuck on this as well. Can this be merged? |
|
Actually I tested this and this doesn't work for :
|
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Body parameters (
inis"body") are always grouped in a single object, and as such there is no way to set defaults for some of the parameters nested inside that body[1].This change looks deeper into the object for
defaultvalues of the parameters rather than just the overall body. This is to support more flexible configuration of expected parameters inbody, and brings the body support closer to ae.g.pathwhich already supports multiple parameters.This change will look for
defaultparameter values for allobjecttype parameters. This is also recursive, so if anobjecthas a parameter that is anobjectthen this code will look for defaults in that nested object.Note [1]: with the current code, it's not even possible to set a default for the whole body's schema. Defaults are only looked for in
parameter.default, but body defaults would be inparameter.schema.default(seehelpers.js:getParameterValue()) . This has not been changed in the this pull request.Note [2]: this has only been implemented for Swagger 2.0 as I am not familiar with Swagger 1.2, so felt it best to leave 1.2 as-is.