Skip to content
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

Increase strictness of style API validation. #10779

Merged
merged 3 commits into from
Jun 17, 2021
Merged

Conversation

samanpwbb
Copy link
Contributor

Launch Checklist

This PR makes mapbox-api-supported documentation more strict. Require 'type' and 'url' keys, and require that type is one of 'vector', 'raster', or 'raster-dem'. Styles with sources that have no type or url do not work, but it is possible to upload them to the style API.

In mapbox-api-supported spec validation, require 'type' and 'url' keys, and require that type is one of 'vector', 'raster', or 'raster-dem'.

cc: @mapbox/map-design-team @mapbox/static-apis

  • briefly describe the changes in this PR
  • include before/after visuals or gifs if this PR includes visual changes
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page
  • tagged @mapbox/map-design-team @mapbox/static-apis if this PR includes style spec API or visual changes
  • tagged @mapbox/gl-native if this PR includes shader changes or needs a native port
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog></changelog>

Copy link
Contributor

@jseppi jseppi left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on, @samanpwbb!

src/style-spec/validate_mapbox_api_supported.js Outdated Show resolved Hide resolved
src/style-spec/validate_mapbox_api_supported.js Outdated Show resolved Hide resolved
@@ -1,18 +1,18 @@
[
{
"line": 23,
"message": "layers[1].paint.sky-atmosphere-sun[0]: -1 is less than the minimum value 0"
"message": "layers[1].paint.sky-atmosphere-sun[0]: -1 is less than the minimum value 0",
Copy link
Contributor

Choose a reason for hiding this comment

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

should this file have been changed?

@@ -1,10 +1,10 @@
[
{
"line": 16,
"message": "layers[0].paint.line-dasharray[1]: -2 is less than the minimum value 0"
"message": "layers[0].paint.line-dasharray[1]: -2 is less than the minimum value 0",
Copy link
Contributor

Choose a reason for hiding this comment

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

should this file have been changed?

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 bet these changes are related to using a different version of node.js to update fixtures.

Copy link
Contributor

Choose a reason for hiding this comment

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

No strong preference here. Seems like a dependency switched their implementation or like someone switched to a Map since non-numeric keys should remain ordered consistently. Could manually un-reorder them to reduce git-blame noise, but doesn't seem like big deal either way.

@samanpwbb samanpwbb requested a review from jseppi June 16, 2021 16:43
@samanpwbb
Copy link
Contributor Author

Back to you @jseppi

/*
* "type" is required and must be one of "vector", "raster", "raster-dem"
*/
if (!acceptedSourceTypes.has(String(source.type))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to use the String constructor here because gl js validation uses @mapbox/jsonlint-lines-primitives to parse strings into JSON, which turns primitives into objects with a line number property.

Copy link
Contributor

Choose a reason for hiding this comment

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

Whoa fancy

Copy link
Contributor

@jseppi jseppi left a comment

Choose a reason for hiding this comment

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

LGTM

/*
* "type" is required and must be one of "vector", "raster", "raster-dem"
*/
if (!acceptedSourceTypes.has(String(source.type))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Whoa fancy

@samanpwbb samanpwbb merged commit 8ffa21f into main Jun 17, 2021
@samanpwbb samanpwbb deleted the strict-source-validation branch June 17, 2021 14:20
rreusser pushed a commit that referenced this pull request Jun 17, 2021
* Increase strictness of style API validation.
rreusser added a commit that referenced this pull request Jun 17, 2021
* Increase strictness of style API validation. (#10779)

* Remove strictly-increasing fog range validation (#10772)

* Fix #10763 (#10767)

Co-authored-by: Saman Bemel-Benrud <[email protected]>
Co-authored-by: Karim Naaji <[email protected]>
SnailBones pushed a commit to SnailBones/mapbox-gl-js that referenced this pull request Jul 15, 2021
* Increase strictness of style API validation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants