Skip to content

Commit

Permalink
refactor: use aep-lib-go (#47)
Browse files Browse the repository at this point in the history
removing logic upstreamed to aep-lib-go.

aep-lib-go provides it's own representation of
APIs. Using that the source of truth in the 
codebase, over the aepc-specific parsed service,
will hopefully deduplicate code in the future
by providing a single API representation among
AEP codebases.

linter has been updated to correctly identify
resources, and there's some existing bugs.

Disabling for now to move this quite painful
refactor in. rule violations will be fixed 
in follow-up commits.
  • Loading branch information
toumorokoshi authored Nov 30, 2024
1 parent c1a0818 commit 3e08e96
Show file tree
Hide file tree
Showing 21 changed files with 1,603 additions and 2,319 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ jobs:
run: |
./scripts/test_http_api.sh
- name: run api-linter
run: |
./scripts/run-api-linter.sh
# - name: run api-linter
# run: |
# ./scripts/run-api-linter.sh
13 changes: 6 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/aep-dev/aepc/parser"
"github.com/aep-dev/aepc/schema"
"github.com/aep-dev/aepc/validator"
"github.com/aep-dev/aepc/writer/openapi"
"github.com/aep-dev/aepc/writer/proto"
"github.com/spf13/cobra"
"google.golang.org/protobuf/encoding/protojson"
Expand Down Expand Up @@ -69,23 +68,23 @@ func ProcessInput(inputFile, outputFilePrefix string) error {
if len(errors) > 0 {
return fmt.Errorf("error validating service: %v", errors)
}
ps, err := parser.NewParsedService(s)
api, err := parser.ToAPI(s)
if err != nil {
return fmt.Errorf("error parsing service: %w", err)
return fmt.Errorf("error building api: %w", err)
}
proto, err := proto.WriteServiceToProto(ps, outputDir)
proto, err := proto.WriteServiceToProto(api, outputDir)
if err != nil {
return fmt.Errorf("error writing service proto %w", err)
return fmt.Errorf("error writing service proto: %w", err)
}
protoFile := fmt.Sprintf("%s.proto", outputFilePrefix)
err = WriteFile(protoFile, proto)
if err != nil {
return fmt.Errorf("error writing file: %w", err)
}
fmt.Printf("output proto file: %s\n", protoFile)
openapi, err := openapi.WriteServiceToOpenAPI(ps)
openapi, err := api.ConvertToOpenAPIBytes()
if err != nil {
return fmt.Errorf("error building openapi %s", err)
return fmt.Errorf("error building openapi: %w", err)
}
openapiFile := fmt.Sprintf("%s_openapi.json", outputFilePrefix)
err = WriteFile(openapiFile, openapi)
Expand Down
Loading

0 comments on commit 3e08e96

Please sign in to comment.