-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·36 lines (29 loc) · 1.46 KB
/
update.sh
File metadata and controls
executable file
·36 lines (29 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Remove previously generated code
rm -rvf ./client
# Try to download the OpenAPI spec from the running FastComments server
if wget -q http://localhost:3001/js/swagger.json -O ./openapi.json; then
echo "Downloaded OpenAPI spec from running server"
SPEC_FILE="./openapi.json"
else
echo "Server not running, using local OpenAPI spec"
SPEC_FILE="./openapi.yaml"
fi
# Generate the Rust client using openapi-generator
java -jar ../openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
-i "$SPEC_FILE" \
-g rust \
-o ./client \
--additional-properties=useSingleRequestParameter=true,disallowAdditionalPropertiesIfNotPresent=false \
-c config.json \
-t .openapi-generator/templates
echo "Generated Rust client in ./client"
# Fix import paths for nested module structure
echo "Fixing import paths..."
find ./client/src -type f -name "*.rs" -exec sed -i 's/use crate::{apis::ResponseContent, models}/use crate::client::{apis::ResponseContent, models}/g' {} \;
find ./client/src -type f -name "*.rs" -exec sed -i 's/use crate::models;/use crate::client::models;/g' {} \;
find ./client/src -type f -name "*.rs" -exec sed -i 's/crate::apis::urlencode/crate::client::apis::urlencode/g' {} \;
# Remove files that prevent cargo publish from including client directory
echo "Removing client/.gitignore and client/Cargo.toml..."
rm -f ./client/.gitignore ./client/Cargo.toml
echo "Client generation complete!"