使用 openapi-generator-cli 生成代码,以 3GPP TS29518_Namf_Communication 为例

使用 openapi-generator-cli 生成代码,以 3GPP TS29518_Namf_Communication 为例

安装 openapi-generator-cli (前提有安装Java 11 以上)

# 使用阿里云镜像
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://maven.aliyun.com/repository/public/org/openapitools/openapi-generator-cli/7.9.0/openapi-generator-cli-7.9.0.jar

生成客户端代码

java -jar .\openapi-generator-cli.jar  generate --skip-validate-spec -g go  --config demo-client-config-29518.yaml  -i 5GC_APIs-Rel-18\5GC_APIs-Rel-18\TS29518_Namf_Communication.yaml -o  TS29518_Namf_Communication_Client
# demo-client-config-29518.yaml
disallowAdditionalPropertiesIfNotPresent: "true"
enumClassPrefix: "true"
generateInterfaces: "true"
generateMarshalJSON: "true"
hideGenerationTimestamp: "false"
isGoSubmodule: "true"
packageName: "XXXXXX"
packageVersion: "v10.0.0"
prependFormOrBodyParameters: "true"
structPrefix: "true"
useOneOfDiscriminatorLookup: "false"
withAWSV4Signature: "false"
withGoMod: "true"
withXml: "true"

生成服务端代码

java -jar .\openapi-generator-cli.jar  generate --skip-validate-spec -g go-gin-server  --config demo-server-config-29518.yml  -i 5GC_APIs-Rel-18\5GC_APIs-Rel-18\TS29518_Namf_Communication.yaml -o  TS29518_Namf_Communication_Server
# demo-server-config-29518.yml
apiPath : "XXXXXXX"
enumClassPrefix : false
hideGenerationTimestamp : false
packageName : "XXXXXX"
packageVersion : "v1.0.0"
serverPort : "8080"

你可能感兴趣的:(问题备忘,开发语言)