ComponentHasDynamicConfigurationSchema

Add this interface to your component to add support for a dynamic configuration field schema. This is useful when the configuration of your component requires talking to your service such as selecting a table from a list of tables gathered from a database.

Applies to: data-* component types

Source: Github

Example:

package my.org.components;

import io.dexi.service.AppContext;
import io.dexi.service.Schema;
import io.dexi.service.components.AppComponent;
import io.dexi.service.components.ComponentHasDynamicConfigurationSchema;
import io.dexi.service.components.DataSourceAppComponent;
import io.dexi.service.utils.ResultStream;
import my.org.data.MyAppConfig;
import my.org.data.MyComponentConfig;

@AppComponent("read-data-from-my-app")
public class MyAppDataSourceAppComponent implements DataSourceAppComponent<MyAppConfig, MyComponentConfig>,
                                                    ComponentHasDynamicConfigurationSchema<MyAppConfig, MyComponentConfig> {


    @Override
    public void read(AppContext<MyAppConfig, MyComponentConfig> ctxt, String offset, int batchSize, ResultStream resultStream)  {
        /* ... component implementation ... */
    }

    @Override
    public Schema getConfigurationSchema(AppContext<MyAppConfig, MyComponentConfig> ctxt) {
        Schema schema = new Schema();
        final Schema.Field dynamicField = new Schema.Field();
        dynamicField.setTitle("A dynamic field");
        dynamicField.setRequired(true);
        schema.put("myFirstField", dynamicField);
        return schema;
    }

    @Override
    public Class<MyComponentConfig> getComponentConfigClass() {
        return MyComponentConfig.class;
    }
}
components:
- name: read-data-from-my-app
  type: data-source
  title: Read data from my app
  specification:
    dynamicConfiguration: # Add the configuration endpoint here
      url: "${baseUrl}/dexi/data/dynamic-configuration/read"
      method: POST
    endpoint:
      url: "${baseUrl}/dexi/data/source/read"
      method: POST
    outputs:
      id: 
        type: number
        title: ID