(完了)コード生成ツールの選択 #4
Locked
yamamoto-febc
started this conversation in
Development
Replies: 4 comments 4 replies
-
|
openapi-generatorの場合: コード生成自体ができない $ docker run -it --rm -v $PWD:$PWD -w $PWD openapitools/openapi-generator-cli:latest generate -i definitions/swagger.json -g go -o fff/
Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
| Error count: 2, Warning count: 1
Errors:
-attribute paths.'/servers/{server_id}/ports/{port_id}/assign_network/'(post).requestBody.content.'application/json'.schema.default is not of type `array`
-attribute paths.'/servers/{server_id}/port_channels/{port_channel_id}/configure_bonding/'(post).requestBody.content.'application/json'.schema.default is not of type `array`
Warnings:
-attribute paths.'/servers/{server_id}/ports/{port_id}/assign_network/'(post).requestBody.content.'application/json'.schema.default is not of type `array`
-attribute paths.'/servers/{server_id}/port_channels/{port_channel_id}/configure_bonding/'(post).requestBody.content.'application/json'.schema.default is not of type `array`
at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:546)
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:573)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:433)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)oapi-codegenの場合: コード生成はできるがコンパイルエラーとなる $ oapi-codegen -generate=types,client -package phy -o phy_gen.go definitions/swagger.json
$ make go imports
$ make test
# github.com/sacloud/libphy
./phy_gen.go:909:13: undefined: Generic401ErrorCode
./phy_gen.go:3354:14: undefined: N401ErrorCode
./phy_gen.go:3389:14: undefined: N401ErrorCode
./phy_gen.go:3428:14: undefined: N401ErrorCode
./phy_gen.go:3463:14: undefined: N401ErrorCode
./phy_gen.go:3501:14: undefined: N401ErrorCode
./phy_gen.go:3537:14: undefined: N401ErrorCode
./phy_gen.go:3590:14: undefined: N401ErrorCode
./phy_gen.go:3624:14: undefined: N401ErrorCode
./phy_gen.go:3662:14: undefined: N401ErrorCode
./phy_gen.go:3662:14: too many errors
make: *** [test] Error 2
|
Beta Was this translation helpful? Give feedback.
4 replies
-
|
定義と違うデータ型が返されるケースがありそう。 // 試しに書いてみたコードでのエラー
json: cannot unmarshal number into Go struct field .servers.spec.cpu_clock_speed of type string定義部 cpu_clock_speed:
type: string
description: CPUクロック数(GHz)
example: '2.1'実際のレスポンス: "cpu_clock_speed": 3, |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
現時点では https://github.com/deepmap/oapi-codegen を採用しつつ、定義の書き方や誤りについてフィードバックして根本から解決していく。 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
#5 で対応 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Go向けのコード生成ツールとして以下のようなものがある。
しかし、どちらを利用してもコンパイルエラーが出る。どう対応していくか?
Beta Was this translation helpful? Give feedback.
All reactions