Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

[PDE-724] (BREAKING) Change omitEmptyParams to removeMissingValuesFrom #63

Merged
merged 3 commits into from
Mar 1, 2019

Conversation

stevelikesmusic
Copy link
Contributor

Description

We're changing omitEmptyParams to removeMissingValuesFrom for more flexibility and descriptiveness. Linked to the core PR doing the same.

Jira

https://zapierorg.atlassian.net/browse/PDE-724

@@ -0,0 +1,23 @@
'use-strict';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two questions:

  1. Is it worth creating a separate schema for this definition? I thought so since it's a new object, but can we define object literals within the schema? It seemed more confusing to me to say it's an object and then try to describe the object in the description.

  2. If we should create a new schema type here, any suggestions on a better name? I'm not the biggest fan of this one 🤔

Copy link
Member

Choose a reason for hiding this comment

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

I agree it's better to define object literals within the schema because it's only used by RequestSchema and not elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just for clarity @eliangcs, are you saying go with defining an object literal in the description, or stick with something like RequestTokenOptionsSchema?

Copy link
Member

Choose a reason for hiding this comment

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

I'm saying instead of a separate file for RequestTokenOptionsSchema, we can define removeMissingValuesFrom schema right below its description, so we don't have to worry about the name. Something like:

// in RequestSchema.js
      removeMissingValuesFrom: {
        description:
          'Should missing values be sent? (empty strings, `null`, and `undefined` only — `[]`, `{}`, and `false` will still be sent)',
        properties: {
          params: {
            description:
              'Refers to data sent via a requests query params (`req.params`)',
            type: 'boolean',
            default: false
          },
          body: {
            description: 'Refers to tokens sent via a requsts body (`req.body`)',
            type: 'boolean',
            default: false
          }
        }
      }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok perfect! thanks @eliangcs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I see where we would get the keys added @eliangcs. Properties doesn't get added to the docs if they aren't a part of a separate schema. So, we could just put everything in the description of removeMissingValuesFrom in addition to properties?

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with both options: 1) put everything in the description or 2) have a separate schema. @xavdid do you have a preference?

If we go with option 2, my only opinion would be the schema name should avoid the term "token". We could use a name like "RequestMissingValuesRemovalOptionsSchema".

If we go with option 1, remember to add an additionalProperties: false next to properties so it forbids properties other than params and body.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have strong feelings. I think we've got other one-off schemas, so if we go that route it's not a big deal. Inline with good descriptions is also perfectly fine. If we need it in another spot, we can break it out then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @xavdid @eliangcs. Ended up going with the inline option.

@@ -0,0 +1,23 @@
'use-strict';
Copy link
Member

Choose a reason for hiding this comment

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

I agree it's better to define object literals within the schema because it's only used by RequestSchema and not elsewhere.

"A set of boolean values that determine how to replace curly strings such as '{{bundle.inputData.foo}} with its actual value.",
type: 'object',
properties: {
queryParams: {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be params instead of queryParams?

@eliangcs eliangcs changed the title [PDE-724] Change omitEmptyParams to removeMissingValuesFrom [PDE-724] (BREAKING) Change omitEmptyParams to removeMissingValuesFrom Feb 25, 2019
@stevelikesmusic stevelikesmusic merged commit 457fedf into master Mar 1, 2019
@stevelikesmusic stevelikesmusic deleted the feature/change-omitEmptyParams-name branch March 1, 2019 19:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants