Skip to content

mtso/json-schema-plugins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Schema Plugin

Install

plugins {
    id 'io.mtso.jsonschema.prepare' version '1.1.0'
}

See: https://plugins.gradle.org/plugin/io.mtso.jsonschema.prepare

Task: prepareSchemas

De-references JSON schemas in the 'from' directory. And copies the de-referenced schemas to the 'into' directory.

build.gradle Configuration

jsonschema {
    prepare {
        from = layout.projectDirectory.dir("schemas/endpoints")
        into = layout.buildDirectory.dir("expanded-schemas")
        exclude "**/shared/**"

        validate {
            include "**schema.json"
            include "**example.*.json"
            exclude "**openapi.schema.json"

            // Optional, defaults to value below.
            examplePattern = '^(.*\\.)example\\.[a-zA-Z_\\d]+(\\.json)$'
            schemaFileExtension = 'schema.json'
        }
    }
}

compileJava {
    dependsOn prepareSchemas
}

Development

Set version in build.gradle to 9999-SNAPSHOT. Then run: ./gradlew publish to publish the plugin to the local plugin repository.

In the local using project, add this to build.gradle:

buildscript {
    repositories {
        maven {
            name = 'localPluginRepository'
            url System.properties['user.home'] + '/dev/repo/local-plugin-repository'
        }
    }
    dependencies {
        classpath "io.mtso:jsonschema:9999-SNAPSHOT"
    }
}

apply plugin: 'io.mtso.jsonschema.prepare'

About

Gradle plugin for dereferencing and validating JSON schemas.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages