JSON schema wrapper types

It is possible to generate schema wrapper types based on the JSON schema definitions. As you need to generate the wrapper classes explicitly (and not at build time like other code generators), you need to check the generated classes into source control. The generated classes do not represent DTO objects (Data Transfer Objects), but instead represent wrappers around a JsonObject object.

To make use of the generated wrapper classes, you can do one of the following:
  • Create a new wrapper instance that contains a new, empty JsonObject object
  • Wrap an existing JsonObject instance

For more information on the JSON schema wrapper classes, see the Guidewire JSON specification in the PolicyCenter Integration Guide.

Generate schema wrapper classes

JSON schema wrapper classes contain statically typed getter and setter methods on the specified object.

Procedure

  1. In Guidewire studio, create a codegen-schemas.txt file in the following directory, if one does not already exist:
    • configuration > config > integration > schemas
  2. In codegen-schemas.txt, list the fully qualified names of the schemas for which you want to generate wrapper classes, each schema on its own separate line.
    For example, enter the fully qualified name of a schema in the following form:
    • gw.pl.system.cluster_tools-1.0

    Use a dot separator (.), not a slash (/) and leave off the .schema.json file ending.

  3. On the Studio toolbar, select Run > Edit Configurations.
    This action opens a Run/Debug Configurations dialog.
  4. In the dialog toolbar, click +, then select Application from the drop-down.
    This action adds a new unnamed, node under Application.
  5. Enter the following data in the dialog fields:
    OptionDescription
    Name codgen
    Main class com.guidewire.tools.json.JsonSchemaWrapperCodegenTool
    Working directory Enter the root directory of your PolicyCenter installation, for example:
    • C:/PolicyCenter/10.1.2/
    Use classpath of module configuration
    Before launch: Make (including OSGI Bundles), Activate tool window Select Make (Including OSGI Bundles) .

    You can accept the defaults for the remainder of the dialog fields, or, change the fields to meet your specific needs.

  6. On the Studio toolbar, select Run > codegen.
    Studio opens a pane at the bottom of the Studio screen that logs the activity of the code generation operation. After the code generation operation completes, Studio places the generated wrapper classes in the following directory in Studio:
    • configuration > src > jsonschema
  7. If you are using source control for the PolicyCenter application files managed by Studio, you need to check the newly generated class files into source control as well.