Skip to content

Generate and store a combined config schema #5607

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

Open
wants to merge 1 commit into
base: shauns/04-04-store_module_schemas_alongside_app
Choose a base branch
from

Conversation

shauns
Copy link
Contributor

@shauns shauns commented Apr 4, 2025

Add JSON schema support for app configuration validation

WHY are these changes introduced?

This PR generates a JSON schema for the app configuration file, which will enable better editor integration and validation for developers working with Shopify app configurations.

WHAT is this pull request doing?

Schema is a combination of locally specified schemas -- i.e. because the input format !== the submission format -- and JSON schema contracts.

  • Adds a hardcodedInputJsonSchema property to extension specifications to support schema validation
  • Implements schema bank generation that creates pretty-printed JSON schema files in the .shopify/schemas directory
  • Generates a combined app configuration schema that merges properties from all config modules
  • Prioritizes hardcoded schemas over validation schemas when both are present
  • Ensures schemas are properly formatted with consistent indentation for better readability
  • Cleans up old schema files that are no longer needed

How to test your changes?

Run at least one CLI command. Add #: schema ./.shopify/schemas/app.schema.json to the top of your app.toml file. See validation and autocomplete magic.

Copy link
Contributor Author

shauns commented Apr 4, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@shauns shauns force-pushed the shauns/04-04-generate_and_store_a_combined_config_schema branch from cd4608e to c3de307 Compare April 4, 2025 14:06
Copy link
Contributor

github-actions bot commented Apr 4, 2025

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/fs.d.ts
@@ -103,13 +103,13 @@ export declare function writeFile(path: string, data: string | Buffer, options?:
  */
 export declare function writeFileSync(path: string, data: string): void;
 /**
- * Creates a directory at the given path.
+ * Creates a directory at the given path. Directories are created recursively if needed.
  *
  * @param path - Path to the directory to be created.
  */
 export declare function mkdir(path: string): Promise<void>;
 /**
- * Synchronously creates a directory at the given path.
+ * Synchronously creates a directory at the given path. Directories are created recursively if needed.
  *
  * @param path - Path to the directory to be created.
  */
@@ -263,6 +263,13 @@ interface GenerateRandomDirectoryOptions {
  * @returns It returns the name of the directory.
  */
 export declare function generateRandomNameForSubdirectory(options: GenerateRandomDirectoryOptions): Promise<string>;
+/**
+ * Read the contents of a directory.
+ *
+ * @param path - Path to the directory.
+ * @returns A promise that resolves to an array of the names of the files in the directory.
+ */
+export declare function readdir(path: string): Promise<string[]>;
 /**
  * Traverse the file system and return pathnames that match the given pattern.
  *

@shauns shauns marked this pull request as ready for review April 4, 2025 14:11
@shauns shauns requested a review from a team as a code owner April 4, 2025 14:11
Copy link
Contributor

github-actions bot commented Apr 4, 2025

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run "pnpm changeset add" to track your changes and include them in the next release CHANGELOG.

Copy link
Contributor

github-actions bot commented Apr 4, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
76.63% (+0.03% 🔼)
9435/12313
🟡 Branches
71.78% (+0.02% 🔼)
4622/6439
🟡 Functions
76.36% (+0.01% 🔼)
2448/3206
🟡 Lines
77.15% (+0.02% 🔼)
8921/11563
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / ConcurrentOutput.tsx
98.36% (-1.64% 🔻)
88% (-4% 🔻)
100%
98.33% (-1.67% 🔻)

Test suite run success

2182 tests passing in 954 suites.

Report generated by 🧪jest coverage report action from c3de307

Copy link
Contributor

I tried to test this but my app.schema.json is missing all the modules schemas 🤔

i'm getting this:

{
  "type": "object",
  "properties": {
    "client_id": {
      "type": "string"
    },
    "organization_id": {
      "type": "string"
    },
    "build": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "required": [
    "client_id"
  ],
  "additionalProperties": true
}

Copy link
Contributor Author

shauns commented Apr 8, 2025

@isaacroldan you'll need DCDD enabled. I don't think any other of the config modules export a portable schema right now.

Copy link
Contributor

ah! that makes sense, in the next PRs in the stack i see you add the hardcoded schemas

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.

2 participants