mapbox / mapbox/mapbox-gl-js

Code generation from mapbox style JSON schema.

Open
#13,572 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Motivation

Goal: generate C# classes from mapbox style JSON schema to have type safe access to the mapbox style from C#. The intent here is to read the mapbox style json file, parse it, and extract style info (colors, line styles) from it for a conversion to CAD.

Problem: There is a JSON schema available for the mapbox style, however it is unclear to what extent it adheres to the official JSON schema spec. This page hints it is a JSON schema: https://docs.mapbox.com/style-spec/guides/, see bottom paragraph "Developer resources" that explicitly mentions and links to JSON schema. However the schema provided at https://github.com/mapbox/mapbox-gl-js/blob/main/src/style-spec/reference/v8.json does not pass validation. Example JSON schema validator here: https://www.jsonschemavalidator.net/. So this blocks the road to standard JSON schema parsers and code generators like Corvus.JsonSchema.

Design Alternatives

So my questions/requests are:

  1. Is the intent for v8.json to adhere to the JSON schema schema (e.g. Schema draft 2020-12)?
  2. The validator only reports 2 errors, I suspect it might be possible to make it pass validation with small modifications. Could you provide such a patched schema to facilitate use of standard tooling?
  3. If the meta schema is quite different from the standard meta schema Schema draft 2020-12, can you provide the meta schema that mapbox used to define the mapbox style JSON schema?
  4. From the code generation in https://github.com/mapbox/mapbox-gl-js/blob/main/build/generate-typed-style-spec.ts it looks like automatic code generation can be done mostly automatically, but there are some hard coded bits regarding to the class hierarchy? What is your perspective on generating code from the mapbox style JSON schema? Is this a maintainable path for us in the future, or do you recommend taking another path?

Design

Depends on answers to questions above.

Mock-Up

Depends on answers to questions above.

Concepts

Depends on answers to questions above.

Implementation

Depends on answers to questions above.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing src/style-spec/reference/v8.json and build/generate-typed-style-spec.ts, then reproduce the reported validation errors against the referenced JSON Schema standard. The issue is not ready to implement: its open questions must be resolved first, including the intended schema dialect, any required schema changes, and whether generated C# access is a maintainable path.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, json, typescript
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.