在 PolicyCenter 中创建基本 REST API

And*_*erg 0 guidewire

我正在尝试在 PolicyCenter 中创建基本的 HelloWorld REST API。GET /apis我从的端点(从)收到内部服务器错误com.guidewire.pl.rest.docs.ApiListGenerator,并且我的新端点返回 404 Not Found。我不确定缺少什么,并且在日志中没有看到任何线索。欢迎任何提示。

获取 http://localhost:8180/pc/rest/apis

{
  "status": 500,
  "errorCode": "java.lang.IllegalArgumentException",
  "cause": {
    "class": "java.lang.IllegalArgumentException",
    "message": "Keys in JsonObject cannot be null"
  },
  "stackTrace": [
    "gw.api.json.JsonObject.validateKey(JsonObject.java:898)",
    "gw.api.json.JsonObject.put(JsonObject.java:849)",
    "com.guidewire.pl.rest.docs.ApiListGenerator.lambda$createApiListJson$2(ApiListGenerator.java:37)",
    "java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)", 
    ...
Run Code Online (Sandbox Code Playgroud)

获取 http://localhost:8180/pc/rest/helloworld

{ 
  "status": 404,
  "errorCode": "gw.api.rest.exceptions.NotFoundException", 
  "userMessage": "No resource was found at path /helloworld"
}
Run Code Online (Sandbox Code Playgroud)

[模块\配置\gsrc\myorg\pc\integration\restapi\helloworld\HelloWorldHandler.gs]

package myorg.pc.integration.restapi.helloworld    

class HelloWorldHandler {

  public function getHelloWorld() : String {
    return 'Hello, World!'
  }

}
Run Code Online (Sandbox Code Playgroud)

[模块\配置\配置\集成\apis\myorg\pc\helloworld\helloworld-1.0.swagger.yaml]

swagger: "2.0"
info:
  version: "1.0"
  title: "Hello World API"
x-gw-apihandlers:
  - myorg.pc.integration.restapi.helloworld.HelloWorldHandler
paths:
  /helloworld:
    get:
      summary: "Says 'Hello World'"
      description: "Says 'Hello World'"
      operationId: getHelloWorld
      produces:
        - text/plain
      responses:
        '200':
          description: |
            Successful operation
          schema:
            type: string
Run Code Online (Sandbox Code Playgroud)

[模块\配置\配置\集成\apis\published-apis.yaml]

apis:
- name: myorg.pc.helloworld.helloworld-1.0
defaultTemplate:
- name: gw.pl.framework.dev_template-1.0
Run Code Online (Sandbox Code Playgroud)

小智 5

我很高兴看到您已经解决了问题,但我想提请您注意,产品文档已更新,包含有关此主题的大量文档。如果您从 Guidewire 社区访问 Guidewire 文档并搜索“配置 REST API”,您将找到有关主题的综合文档,例如如何构建映射器和更新器,这些映射器和更新器以最小或最小的方式将请求/响应有效负载映射到 Guidewire 类型。无需代码、如何管理身份验证、如何通过 IRestDispatchPlugin 调度插件执行预处理和后处理、有关日志记录的最佳实践、如何本地化响应负载等等。