Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ jobs:
GOPRIVATE: github.com/phrase/phrase-go
run: |
npm install
npm run generate.go
npm run generate.cli
# Verify the generated CLI compiles before publishing it. Build against
# the freshly generated go client so this does not depend on a released
# phrase-go version that may lag behind the spec.
(cd ./clients/cli && go mod edit -replace github.com/phrase/phrase-go/v4=../go && go build . && go mod edit -dropreplace github.com/phrase/phrase-go/v4)
git clone https://$API_TOKEN_GITHUB@github.com/phrase/phrase-cli.git clones/cli &> /dev/null
rsync -avI --delete --exclude='.git/' clients/cli/ clones/cli
cd clones/cli
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/test-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
# Once we add tests, we should add a step here to run them
name: Run CLI Tests
on:
push:
pull_request:
paths:
- .github/workflows/test-cli.yml
- 'paths/**'
- 'paths.yaml'
- 'schemas/**'
- 'schemas.yaml'
- 'parameters.yaml'
- 'responses.yaml'
Comment thread
Copilot marked this conversation as resolved.
- 'headers.yaml'
- 'main.yaml'
- 'openapi-generator/templates/cli/**'
- openapi-generator/cli_lang.yaml
- 'clients/cli/**'
- .github/workflows/test-cli.yml
jobs:
test:
runs-on: ubuntu-latest
Expand Down
14 changes: 7 additions & 7 deletions openapi-generator/templates/cli/api.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ func init{{{nickname}}}() {
{{#allParams~}}
{{#required~}}
{{#isPrimitiveType~}}
{{#if (eq paramName "file")~}}
{{paramName}}, err := os.Open(params.GetString(helpers.ToSnakeCase("{{paramName}}")))
{{#isFile~}}
{{paramName}}, err := os.Open(params.GetString(helpers.ToSnakeCase("{{{vendorExtensions.x-export-param-name}}}")))
if err != nil {
HandleError(err)
}
{{else~}}
{{paramName}} := params.Get{{{capitalizeFirst dataType}}}(helpers.ToSnakeCase("{{{vendorExtensions.x-export-param-name}}}"))
{{/if}}
{{/isFile}}
{{else~}}
var {{paramName}} api.{{{dataType}}}
if err := json.Unmarshal([]byte(params.GetString("data")), &{{paramName}}); err != nil {
Expand All @@ -72,9 +72,9 @@ func init{{{nickname}}}() {
}
{{/isPrimitiveType~}}
{{else~}}
{{#if (or (eq paramName "file") (eq paramName "filename"))~}}
if params.IsSet(helpers.ToSnakeCase("{{paramName}}")) {
file, err := os.Open(params.GetString(helpers.ToSnakeCase("{{paramName}}")))
{{#isFile~}}
if params.IsSet(helpers.ToSnakeCase("{{{vendorExtensions.x-export-param-name}}}")) {
file, err := os.Open(params.GetString(helpers.ToSnakeCase("{{{vendorExtensions.x-export-param-name}}}")))
localVarOptionals.{{{vendorExtensions.x-export-param-name}}} = optional.NewInterface(file)
if err != nil {
HandleError(err)
Expand Down Expand Up @@ -111,7 +111,7 @@ func init{{{nickname}}}() {
localVarOptionals.{{{vendorExtensions.x-export-param-name}}} = {{#if (eq dataType "[]string")}}{{paramName}}{{else}}optional.NewInterface({{paramName}}){{/if}}
}
{{/isModel}}{{/isPrimitiveType}}
{{/if}}
{{/isFile}}
{{/required~}}
{{/allParams~}}

Expand Down
Loading