主页文档代码示例API 参考公告模型发行说明常见问题GitHub视频
开发者中心API 状态支持
文档
开发者中心API 状态支持

生成 Java 客户端库

生成 Java 客户端库。

These instructions show you how to generate a Java client library for the Sellers API using Swagger Code Generator on a computer running Microsoft Windows. The process is the same for users of other operating systems such as macOS or Linux, with the replacement of Windows-specific semantics (for example, C:\). Although these instructions are for the Sellers API, you can modify the instructions to make client libraries for other APIs in the Selling Partner API. Refer to Models for Swagger models for each Selling Partner API section.

While a generated client library can help you make calls to the Selling Partner API, it does not contain code for LWA token exchange and authentication. For that, refer to Step 1. Request a Login with Amazon access token and Step 4. Create and sign your request. Or, for an SDK that includes LWA token exchange, refer to Generating a Java SDK with LWA token exchange.

生成 Java 客户端库

  1. Install Java 8 or newer, Apache Maven 3.6. or greater, and GNU Wget and make them available in your $PATH.

  2. Go to Models.

  3. 克隆存储库以在计算机上创建本地副本(如果尚未执行此操作)。

  4. 打开命令提示符窗口,然后导航到要下载 Swagger 代码生成器的目录。

  5. 下载最新版本的 Swagger 代码生成器。

    例如:

    wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.13/swagger-codegen-cli-2.4.13.jar -O swagger-codegen-cli.jar

    swagger-codegen-cli.jar downloads to the current directory.

    📘

    注意

    你也可以通过将浏览器定向到 maven.org 进行下载 https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.13/swagger-codegen-cli-2.4.13.jar

  6. swagger-codegen-cli.jar 复制到对您有意义的目录结构中。在本例中,我们将把它复制到 C:\\SwaggerToCL

  7. 导航至 sellers.jsonselling-partner-api-models\\models\\sellers-api-model 存储库本地副本的文件夹。

  8. sellers.json + C:\\SwaggerToCL

  9. 生成客户端库。

    例如:

    java -jar C:\SwaggerToCL\swagger-codegen-cli.jar generate -i C:\SwaggerToCL\Sellers.json -l java -o C:\SwaggerToCL\Sellers_JavaCL

    客户端库已复制到 C:\\SwaggerToCL\\Sellers_JavaCL

    After you have generated your client library you can use it to help you make calls to the Selling Partner API. Refer to Connecting to Selling Partner API.


此页面对您有帮助吗?