diff --git a/generator/README.md b/generator/README.md new file mode 100644 index 00000000..9ec3ea71 --- /dev/null +++ b/generator/README.md @@ -0,0 +1,38 @@ + +# BrAPI Schema Generator + +Generates the OpenAPI Specification, GraphQL Schema and OWL Model from the JSON Schema. +The files are generated in the Specification/Generated directory. + +### How to use + +To generate all use the following + + * In windows + + ```powershell + ./gradlew generateAll + ``` + + * In Linux or macOS + + ```shell + ./gradle generateAll + ``` +For individual tasks try + +* *generateGraphQL* to generate the GraphQL Schema from the JSON Schema +* *generateOpenAPI* to generate the OpenAPI Specification from the JSON Schema +* *generateOWL* to generate the OWL Model from the JSON Schema +* *validate* to validate the JSON Schema without generating any file + +The files are generated in the Specification/Generated directory. + +to change the version of BrAPI used in the file name edit the *brapiVersion* in +[Settings](settings.gradle). + +### Configuration + +To configure the generator see https://github.com/plantbreeding/brapi-schema-tools + + diff --git a/generator/build.gradle b/generator/build.gradle index 7c9a4afd..c9acfb9b 100644 --- a/generator/build.gradle +++ b/generator/build.gradle @@ -1,7 +1,8 @@ apply plugin : "java" ext { javaMainClass = 'org.brapi.schematools.cli.BrAPICommand' - brapiSchemaToolsVersion = '0.7.0-SNAPSHOT' + brapiSchemaToolsVersion = '0.10.0-SNAPSHOT' + brapiVersion = 'v2_1' } repositories { @@ -28,22 +29,44 @@ tasks.register("generateGraphQL", JavaExec) { classpath = sourceSets.main.runtimeClasspath mainClass = javaMainClass workingDir = '../' + def filename = "Specification/Generated/brapi_" + brapiVersion + ".graphqls" args = ['generate', 'Specification/BrAPI-Schema', '-l', 'GRAPHQL', - '-f', 'Specification/Generated/schema.graphqls', + '-f', filename, '-x'] } tasks.register("generateOpenAPI", JavaExec) { group = 'BrAPI' - description = 'Generate GraphQL schema from the Json Schema' + description = 'Generate OpenAPI schema from the Json Schema' classpath = sourceSets.main.runtimeClasspath mainClass = javaMainClass workingDir = '../' + def filename = "Specification/Generated/brapi_" + brapiVersion + ".json" args = ['generate', 'Specification/BrAPI-Schema', '-l', 'OPEN_API', - '-f', 'Specification/Generated/brapi_openapi.json', - '-c', 'Specification\\OpenAPI-Components', + '-f', filename, + '-c', 'Specification/OpenAPI-Components', '-x'] +} + +tasks.register("generateOWL", JavaExec) { + group = 'BrAPI' + description = 'Generate OWL schema from the Json Schema' + classpath = sourceSets.main.runtimeClasspath + mainClass = javaMainClass + workingDir = '../' + def filename = "Specification/Generated/brapi_" + brapiVersion + ".ttl" + args = ['generate', 'Specification/BrAPI-Schema', + '-l', 'OWL', + '-f', filename, + '-m', 'generator/ont-model-metadata.yaml', + '-x'] +} + +tasks.register("generateAll") { + dependsOn generateGraphQL + dependsOn generateOpenAPI + dependsOn generateOWL } \ No newline at end of file