You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Hyperledger Composer:composer-rest-server生成的Open API规范存储位置及Java客户端生成咨询

Hyperledger Composer: Finding the OpenAPI Spec from composer-rest-server & Generating a Java Client

Great questions! I’ve tackled this exact workflow before, so let’s break it down step by step.

1. Where is the Open API Specification stored by composer-rest-server?

First off: the composer-rest-server doesn’t write the OpenAPI Specification (OAS) to a static local file when it runs. Instead, it dynamically generates the spec on-the-fly and serves it through HTTP endpoints while the server is active.

By default, once your server is up (usually at http://localhost:3000 unless you changed the port during startup), you can access the Swagger/OpenAPI 2.0 spec at:
http://<your-server-host>:<port>/swagger.json

If you configured the server to use OpenAPI 3.0 (via startup flags or config), the endpoint will be:
http://<your-server-host>:<port>/openapi.json

2. How to use this spec with swagger-codegen to generate a Java client?

You’ve got two simple ways to generate your Java client—pick whichever fits your workflow better:

Option 1: Generate directly from the live API endpoint

Run the swagger-codegen command pointing straight to the spec URL. Just make sure the composer-rest-server is still running when you do this. Example command:

swagger-codegen generate -i http://localhost:3000/swagger.json -l java -o ./composer-rest-java-client

This will pull the spec dynamically and generate all the Java client code into the ./composer-rest-java-client directory.

Option 2: Download the spec first, then generate

If you want a local copy of the spec (for version control or offline use):

  1. Use curl or your browser to save the spec file locally:
    curl http://localhost:3000/swagger.json -o composer-rest-swagger.json
    
  2. Run swagger-codegen using the local file:
    swagger-codegen generate -i ./composer-rest-swagger.json -l java -o ./composer-rest-java-client
    

A quick heads-up: The spec is tailored to your specific Hyperledger Composer business network, so make sure the server is running against the correct network when you fetch the spec—otherwise, the generated client won’t match your API endpoints.

内容的提问来源于stack exchange,提问作者blahblahblah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:54:56