octokit / source-generator

Generates SDKs from GitHub's OpenAPI specification. Built on Kiota.
8 stars 4 forks source link

Get to know you #1

Closed kfcampbell closed 1 year ago

kfcampbell commented 1 year ago

This PR holds some fixups I've been making as I've been familiarizing myself with this project.

kfcampbell commented 1 year ago

I'm publishing this PR as the build is failing correctly and I believe all these changes are valid. Future changes will come to fix the build errors.

kfcampbell commented 1 year ago

The build failures here come in 3 different types:

  1. +1 and -1 reactions both serialize as _1, resulting in duplicate models where reactions are concerned.
  2. The enum SquashMergeCommitMessageEnum contains two "BLANK" values when it should contain just one.
  3. The Events enum under the WebhookMetaDeletedHook model has two values (* and star) that both serialize to Star in the enum.

Issue 3 can be fixed easily via a post-processing step: generate.sh can export a magic environment variable to call a script (export CSHARP_POST_PROCESS_FILE="/home/kfcampbell/github/dev/source-generator/csharp-post-process.sh") and add the --enable-post-process-file argument to the openapi-generator-cli generate invocation. The contents of csharp-post-process.sh will look something like this:

#!/usr/bin/env sh

# parse first argument as filename
filename=$1

# find string "/// Enum Star for value: *" and replace with "Enum All for value: *"
sed -i 's/\/\*\* Enum Star for value: \*\*\//Enum All for value: \*/g' $filename

# find string "            Star = 1," and replace with "            All = 1,"
sed -i 's/            Star = 1,/            All = 1,/g' $filename

The first two issues I'm still working through a solution. Using bash to run these scripts is somewhat limiting; tomorrow I may look into using Node/JS to accomplish the post-processing step.

The ideal solution to the second issue is a simple fix in the spec; I'll need to research how to do so.