Skip to content
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

add java codegen from json schema #14

Merged
merged 6 commits into from
Aug 8, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions conduit-config/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
group 'io.dataline.conduit'
version '0.1.0'

//https://github.com/joelittlejohn/jsonschema2pojo/tree/master/jsonschema2pojo-gradle-plugin
Copy link
Contributor Author

@cgardens cgardens Aug 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: i'm a little at a loss here. i think this project is deprecated, but there is a replacement. there are also new releases on maven central. need to do a little more homework to make sure i'm using the right one / non-deprecated one.

apply plugin: 'jsonschema2pojo'


buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath 'org.jsonschema2pojo:jsonschema2pojo-gradle-plugin:1.0.2'
}
}


repositories {
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'

// Required if generating JSR-303 annotations
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: i need to understand these configs a little better, i suspect we just need the jackson and joda ones.

compile 'javax.validation:validation-api:1.1.0.CR2'
// Required if generating Jackson 2 annotations
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.7'
// Required if generating JodaTime data types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you generate in Java8 format? (almost of clone of joda)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably. i'll check.

compile 'joda-time:joda-time:2.2'
}

jsonSchema2Pojo {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "StandardConnectionStatus",
"title": "StandardConnectionStatus",
"description": "describes the result of a 'test connection' action.",
"type": "object",
"required": ["status"],
"properties": {
"status": {
"type": "string",
"enum": ["success", "failure"]
},
"message": {
"type": "string"
}
}
}
52 changes: 52 additions & 0 deletions conduit-config/src/main/resources/json/StandardDataSchema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "StandardDataSchema",
"title": "StandardDataSchema",
"type": "object",
"definitions": {
"schema": {
"description": "describes the available schema.",
"type": "object",
"properties": {
"tables": {
"type": "array",
"items": {
"type": "object",
"required": [
"name",
"columns"
],
"properties": {
"name": {
"type": "string"
},
"columns": {
"type": "array",
"items": {
"type": "object",
"required": [
"name",
"dataType"
],
"properties": {
"name": {
"type": "string"
},
"dataType": {
"type": "string",
"enum": [
"string",
"number",
"boolean"
]
}
}
}
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "StandardDiscoveryOutput",
"title": "StandardDiscoveryOutput",
"description": "describes the standard output for any discovery run.",
"type": "object",
"required": ["schema"],
"properties": {
"schema": {
"description": "describes the available schema.",
"$ref": "StandardDataSchema.json#/definitions/schema"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "StandardScheduleConfiguration",
"title": "StandardScheduleConfiguration",
"type": "object",
"properties": {
"timeUnit": {
"type": "string",
"enum": ["minutes", "hours", "days", "weeks"]
},
"units": {
"type": "integer"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "StandardSyncConfiguration",
"title": "StandardSyncConfiguration",
"description": "configuration required for sync for ALL taps",
"type": "object",
"properties": {
"syncMode": {
"type": "string",
"enum": ["full_refresh", "append"]
},
"schema": {
"description": "describes the elements of the schema that will be synced.",
"$ref": "StandardDataSchema.json#/definitions/schema"
}
}
}
47 changes: 47 additions & 0 deletions conduit-config/src/main/resources/json/StandardSyncSummary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "StandardSyncSummary",
"title": "StandardSyncSummary",
"description": "standard information output by ALL taps for a sync step (our version of state.json)",
"type": "object",
"properties": {
"attemptId": {
"type": "string",
"format": "uuid"
},
"status": {
"type": "string",
"enum": ["pending", "in_progress","completed", "failed", "cancelled"]
},
"recordsSynced": {
"type": "integer",
"minValue": 0
},
"version": {
"type": "integer"
},
"tables": {
"type": "array",
"items": {
"type": "object",
"properties": {
"lastRecord": {
"description": "blob of the last record",
"type": "object"
},
"version": {
"type": "integer"
}
}
}
},
"startTime": {
"type": "integer"
},
"endTime": {
"type": "integer"
},
"logs": {
}
}
}
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ rootProject.name = 'conduit'
include 'conduit-api'
include 'conduit-server'
include 'conduit-commons'
include 'conduit-config'