Skip to content

Commit

Permalink
Make the scripts more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
filipnavara committed May 31, 2024
1 parent 4003602 commit 99574ea
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
6 changes: 5 additions & 1 deletion generate-calendar.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
yq eval '(del(.components.schemas.[].id) | .openapi = "3.0.0" | del(.. | select(has("annotations")).annotations) | .components.schemas.EventWorkingLocationProperties.properties.homeOffice.type = "object" | with(.. | select(.default? == "false"); .default = false) | with(.. | select(.default? == "true"); .default = true) | with(.. | select(.default? == "0"); .default = 0)) * load("error.yaml") | .paths.[].[]?.["responses"]? += {"4XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}} | .paths.[].[]?.["responses"]? += {"5XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}}' google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/calendar/calendar.yaml > src/Google.Apis.Kiota.Calendar/calendar.generated.yaml
./preprocess-openapi-yaml.sh google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/calendar/calendar.yaml > src/Google.Apis.Kiota.Calendar/calendar.generated.yaml
yq eval --inplace '
# Change any to object
.components.schemas.EventWorkingLocationProperties.properties.homeOffice.type = "object"
' src/Google.Apis.Kiota.Calendar/calendar.generated.yaml
kiota generate --openapi src/Google.Apis.Kiota.Calendar/calendar.generated.yaml -o src/Google.Apis.Kiota.Calendar/Generated -l CSharp -n Google.Apis.Kiota.Calendar -c CalendarApiClient -s Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory --ds Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory
rm src/Google.Apis.Kiota.Calendar/Generated/Models/GoogleApiException.cs
rm src/Google.Apis.Kiota.Calendar/Generated/Models/RequestError.cs
Expand Down
2 changes: 1 addition & 1 deletion generate-drive.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
yq eval '(del(.components.schemas.[].id) | .openapi = "3.0.0" | del(.. | select(has("annotations")).annotations) | with(.. | select(.format? == "int64"); .type = "integer")) * load("error.yaml") | .paths.[].[]?.["responses"]? += {"4XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}} | .paths.[].[]?.["responses"]? += {"5XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}}' google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/drive/drive.yaml > src/Google.Apis.Kiota.Drive/drive.generated.yaml
./preprocess-openapi-yaml.sh google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/drive/drive.yaml > src/Google.Apis.Kiota.Drive/drive.generated.yaml
kiota generate --openapi src/Google.Apis.Kiota.Drive/drive.generated.yaml -o src/Google.Apis.Kiota.Drive/Generated -l CSharp -n Google.Apis.Kiota.Drive -c DriveApiClient -s Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory --ds Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory
rm src/Google.Apis.Kiota.Drive/Generated/Models/GoogleApiException.cs
rm src/Google.Apis.Kiota.Drive/Generated/Models/RequestError.cs
Expand Down
2 changes: 1 addition & 1 deletion generate-gmail.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
yq eval '(del(.components.schemas.[].id) | .openapi = "3.0.0" | del(.. | select(has("annotations")).annotations) | del(.. | select(has("enumDescriptions")).enumDescriptions) | with(.. | select(.format? == "int64"); .type = "integer") | with(.. | select(.format? == "uint64"); .type = "integer")) * load("error.yaml") | .paths.[].[]?.["responses"]? += {"4XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}} | .paths.[].[]?.["responses"]? += {"5XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}}' google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/gmail/gmail.yaml > src/Google.Apis.Kiota.Gmail/gmail.generated.yaml
./preprocess-openapi-yaml.sh google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/gmail/gmail.yaml > src/Google.Apis.Kiota.Gmail/gmail.generated.yaml
kiota generate --openapi src/Google.Apis.Kiota.Gmail/gmail.generated.yaml -o src/Google.Apis.Kiota.Gmail/Generated -l CSharp -n Google.Apis.Kiota.Gmail -c GmailApiClient -s Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory --ds Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory
rm src/Google.Apis.Kiota.Gmail/Generated/Models/GoogleApiException.cs
rm src/Google.Apis.Kiota.Gmail/Generated/Models/RequestError.cs
Expand Down
2 changes: 1 addition & 1 deletion generate-people.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
yq eval '(del(.components.schemas.[].id) | .openapi = "3.0.0" | del(.. | select(has("enumDescriptions")).enumDescriptions) | del(.. | select(has("enumDeprecated")).enumDeprecated)) * load("error.yaml") | .paths.[].[]?.["responses"]? += {"4XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}} | .paths.[].[]?.["responses"]? += {"5XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}}' google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/people/people.yaml > src/Google.Apis.Kiota.People/people.generated.yaml
./preprocess-openapi-yaml.sh google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/people/people.yaml > src/Google.Apis.Kiota.People/people.generated.yaml
kiota generate --openapi src/Google.Apis.Kiota.People/people.generated.yaml -o src/Google.Apis.Kiota.People/Generated -l CSharp -n Google.Apis.Kiota.People -c PeopleApiClient -s Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory --ds Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory
rm src/Google.Apis.Kiota.People/Generated/Models/GoogleApiException.cs
rm src/Google.Apis.Kiota.People/Generated/Models/RequestError.cs
Expand Down
2 changes: 1 addition & 1 deletion generate-tasks.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
yq eval '(del(.components.schemas.[].id) | .openapi = "3.0.0") * load("error.yaml") | .paths.[].[]?.["responses"]? += {"4XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}} | .paths.[].[]?.["responses"]? += {"5XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}}' google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/tasks/tasks.yaml > src/Google.Apis.Kiota.Tasks/tasks.generated.yaml
./preprocess-openapi-yaml.sh google-discovery-to-openapi/openapi/googleapis.com/v00.00.00000/services/tasks/tasks.yaml > src/Google.Apis.Kiota.Tasks/tasks.generated.yaml
kiota generate --openapi src/Google.Apis.Kiota.Tasks/tasks.generated.yaml -o src/Google.Apis.Kiota.Tasks/Generated -l CSharp -n Google.Apis.Kiota.Tasks -c TasksApiClient -s Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory --ds Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory
rm src/Google.Apis.Kiota.Tasks/Generated/Models/GoogleApiException.cs
rm src/Google.Apis.Kiota.Tasks/Generated/Models/RequestError.cs
Expand Down
21 changes: 21 additions & 0 deletions preprocess-openapi-yaml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
yq eval '
# Update OpenAPI version
.openapi = "3.0.0" |
# Delete `id`, it was renamed to $id
del(.components.schemas.[].id) |
# Delete annotations
del(.. | select(has("annotations")).annotations) |
# Update default values to match their type
with(.. | select(.default? == "false"); .default = false) |
with(.. | select(.default? == "true"); .default = true) |
with(.. | select(.default? == "0"); .default = 0) |
# Delete non-standard enumDescriptions and enumDeprecated
del(.. | select(has("enumDescriptions")).enumDescriptions) |
del(.. | select(has("enumDeprecated")).enumDeprecated) |
# Update int64 to integer
with(.. | select(.format? == "int64"); .type = "integer") |
# Add error responses
.paths.[].[]?.["responses"]? += {"4XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}} |
.paths.[].[]?.["responses"]? += {"5XX":{"description":"Failure response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleApiException"}}}}} |
. * load("error.yaml")
' $1

0 comments on commit 99574ea

Please sign in to comment.