-
Notifications
You must be signed in to change notification settings - Fork 11
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
APOLLO-24186 Removed schema and Get mentions #71
Open
roblucar
wants to merge
2
commits into
main
Choose a base branch
from
APOLLO-24186-RemoveSchemaAndGetMentions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,11 @@ To build a valid connector configuration, you must: | |
* Apply a few annotations. | ||
* Define connector "getter" methods and annotations. | ||
|
||
All methods that are annotated with `@Property` and start with "get" are considered to be configuration properties. | ||
For example, `@Property() String getName();` results in a String property called `name`. | ||
All methods that are annotated with `@Property` and are considered to be configuration properties. | ||
For example, `@Property() String name();` results in a String property called `name`. | ||
This property would then be present in the generated schema. | ||
|
||
Here is an example of the most basic configuration, along with required annotations and a sample "getter" method: | ||
Here is an example of the most basic configuration, along with required annotations and a sample property access methods: | ||
|
||
```java | ||
@RootSchema( | ||
|
@@ -26,7 +26,7 @@ public interface MyConfig extends ConnectorConfig<MyConfig.Properties> { | |
title = "Properties", | ||
required = true | ||
) | ||
public Properties getProperties(); | ||
public Properties properties(); | ||
|
||
/** | ||
* Connector specific settings | ||
|
@@ -37,7 +37,7 @@ public interface MyConfig extends ConnectorConfig<MyConfig.Properties> { | |
title = "My custom property", | ||
description = "My custom property description" | ||
) | ||
public Integer getMyCustomProperty(); | ||
public Integer myCustomProperty(); | ||
|
||
} | ||
|
||
|
@@ -53,69 +53,3 @@ Once a connector configuration has been defined, it can be associated with the ` | |
From that point, the framework takes care of providing the configuration instances to your connector. | ||
It also generates the schema, and sends it along to Fusion when it connects to Fusion. | ||
|
||
=== About com.lucidworks.schema | ||
The `com.lucidworks.schema` project (included in the connectors SDK) aims to simplify the process of creating JSON Schemas. | ||
It also provides utilities for building type-safe POJOs from schema definitions. | ||
|
||
The basic idea here is that you create an interface that extends `Model`, add property getters, and then add a few annotations. | ||
Once your interface has been built, you can generate an `ObjectType` instance, which is the object that contains all of the JSON schema metadata. | ||
By then combining that schema object with a `Map<String,Object>`, you can create instances of your interface to use as configuration objects. | ||
|
||
The configuration objects are based on `java.lang.reflect.Proxy`, which is what the `ModelGenerator` returns. | ||
Most method calls to these proxy instances result in method calls to the underlying `Map<String,Object>`. | ||
For example, if the interface defines a `getId` method, then a runtime call results in a call to the `Map<String,Object>`: `data.get("id")`. | ||
|
||
A few special cases exist: | ||
|
||
* `toString` is proxied directly to the `Map<String,Object>` | ||
* `getClass` returns the class of the interface provided to `ModelGenerator#generate()` | ||
* `_data` returns the underlying `Map<String,Object>` object | ||
* If the method starts with `set`, the arguments are captured and sent to the underlying map via `put()` | ||
|
||
Here is a simple example: | ||
|
||
```java | ||
interface MyConfig extends Model { | ||
|
||
@Property | ||
@StringSchema(minLength=1) | ||
String getId(); | ||
|
||
} | ||
``` | ||
|
||
Create the schema: | ||
|
||
```java | ||
class Runner { | ||
public static void main(String[] args){ | ||
ObjectType schema = SchemaGenerator.generate(MyConfig.class); | ||
} | ||
} | ||
``` | ||
|
||
Generate an instance of the `MyConfig` class: | ||
|
||
```java | ||
class Runner { | ||
public static void main(String[] args){ | ||
Map<String,Object> data = new java.util.HashMap<>(); | ||
data.put("id", 100); | ||
MyConfig config = ModelGenerator.generate(MyConfig.class, data); | ||
System.out.println("id -> " + config.getId()); | ||
} | ||
} | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is the only section that needs to be removed. The rest of it is relevant to building configs schemas. |
||
|
||
Schema metadata can be applied to properties using additional annotations. For example, applying limits to the min/max length of a string, or describing the types of items in an array. | ||
|
||
Nested schema metadata can also be applied to a single field by using "stacked" schema based annotations: | ||
|
||
```java | ||
interface MySetConfig extends Model { | ||
@SchemaAnnotations.Property(title = "My Set") | ||
@SchemaAnnotations.ArraySchema(defaultValue = "[\"a\"]") | ||
@SchemaAnnotations.StringSchema(defaultValue = "some-set-value", minLength = 1, maxLength = 1) | ||
Set<String> getMySet(); | ||
} | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.