Skip to Content

Validating Prepr schema JSON files

This guide shows you how to validate schema JSON files using a GitHub validation action and the Prepr GraphQL API spec.

Introduction

In the event that you want to maintain your Prepr schema through a code editor, you can validate these schema JSON files before performing a schema import.

This guide is based on using GitHub as your schema repository. Similar steps can be applied to other platforms like GitLab, BitBucket or Azure DevOps, but you might need to create the corresponding validation action or pipeline instead of simply copying the validation YML we provide.

Validating your schema using the Prepr GraphQL API spec

Follow the steps below to validate schema JSON files  against the Prepr GraphQL API spec .

Create your GitHub schema repo

  • If you don’t yet have one, create a GitHub repo  to store the source for your Prepr schema.
  • Make sure to upload the schema JSON files into a /prepr/schema folder structure in your “staging” branch.

Install the Prepr schema validation

  • From your main branch, create the workflow action .github/workflows/prepr-schema-validation.yml in your repository and copy the following code to this file:

    name: Validate Prepr schema on: workflow_dispatch: pull_request: paths: - 'prepr/schema/*.json' push: branches: - main paths: - 'prepr/schema/*.json' jobs: validate-prepr-schema: uses: preprio/action-schema-validation/.github/workflows/prepr-schema-validation.yml@v1
  • Once the workflow is successfully created and active, push your JSON files to the main branch to trigger it.

Import the valid schema

When there are no errors detected from the validation workflow, you can then import the schema into your desired Prepr environment. Check out the Syncing a schema guide for more details on importing a schema using different platforms.

That’s it! You‘ve successfully validated the schema from your current environment to the target environment.

If you have any questions or encounter issues with the schema validation , please reach out to our Support team .

Last updated on