Skip to content

Commit

Permalink
Update _type patch script
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksim Zvankovich committed Jun 29, 2023
1 parent 52aba7d commit 0b90a07
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,19 @@ diff -U20 --color=always \

## Known Issues

To fix the issue [Unable to compile Java openapi client#3](https://github.com/ccouzens/vcloud-rest-openapi/issues/3), run [patch_java_openapi_client.sed](./patch_java_openapi_client.sed) as a temporary workaround
[Unable to compile Java openapi client#3](https://github.com/ccouzens/vcloud-rest-openapi/issues/3)

The temporary workaround:

1. Copy patch scripts [fix-vcd-type-discriminator_01.sed](fix-vcd-type-discriminator_01.sed) and [fix-vcd-type-discriminator_02.sed](fix-vcd-type-discriminator_02.sed) to the root project directory


2. Clean up the codegenerated client <output directory>:
```bash
rm -rf <output directory>
```

3. Run the script from the root project directory:
```bash
find <output directory> -regex '.*\(Type\|Value\|AllOf\|Test\)\.java' -exec grep -H '_type\|typeTest' {} \; -exec sed -ri -f patch_java_openapi_client.sed {} \;
find ./<output directory> -regex '.*\(Type\|Value\)\.java' -exec grep -H 'String JSON_PROPERTY_TYPE = "_type"' {} \; -exec sed -ri -f ./fix-vcd-type-discriminator_01.sed {} \; && find ./<output directory>/ -regex '.*\(Type\|Value\)\.java' -exec grep -H 'extends .*\(Type\|Value\)' {} \; -exec sed -ri -f ./fix-vcd-type-discriminator_02.sed {} \;
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
0,/typeTest/!{0,/typeTest/s/type/_&/};
/JSON_PROPERTY_TYPE = "_type"/,+1 {
s/type/_&/i;
};
Expand Down
11 changes: 11 additions & 0 deletions fix-vcd-type-discriminator_02.sed
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
/@Override/,+2 {
0,/public .+(Type|Value) type\(String type\) \{/ {
/public .+(Type|Value) type\(String type\) \{/ {
N;N;
s/type/_&/;
s/setType/set_Type/;
}
}
}
}

0 comments on commit 0b90a07

Please sign in to comment.