FC2 ブログ

ぎじゅつのメモ

OpenAPI Generatorにプルリクを出した

これ

typescript-fetch: Add application/x-www-form-urlencoded content support by tkrtmy · Pull Request #3934 · OpenAPITools/openapi-generator · GitHub

mustacheテンプレートをイジっただけ
すでにmustacheに渡されてる変数だけでなんとかしようとしたので泥臭い感じ

こちらのissueを解決した形になる github.com

いやーちょうどOpenAPI Generator で生成したTypeScriptクライアントで Content-type: application/x-www-form-urlencoded でリクエストができなくて困ってたんだよね〜

ということで対応してみた。

※追記 対応漏れがあったから、追加でプルリクを出した

github.com

cloneしてからどうやって動かしたかというとこをコマンドだけメモっておく

他の言語やクライアントorサーバーでも適宜読み替えれば同じ内容で対応できるはず

# ビルドして
$ mvn clean install

# テンプレートで使える変数を確認して
$ java -DdebugOperations -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript-fetch
$ java -DdebugModels -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g typescript-fetch

# テンプレートイジってpackage更新
$ mvn clean package

# サンプルプロジェクトを更新
$ ./bin/typescript-fetch-petstore-all.sh

# 一応生成したコードのテストをとりあえずやっておく
$ cd samples/client/petstore/typescript-fetch/tests/default/
$ mvn integration-test -rf :TypeScriptFetchPestoreClientTests