Skip to content

Commit

Permalink
chore: refactor out parsedservice
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
toumorokoshi committed Nov 30, 2024
1 parent 6fa3d63 commit 6833085
Show file tree
Hide file tree
Showing 16 changed files with 1,121 additions and 1,489 deletions.
15 changes: 5 additions & 10 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +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)
api, err := parser.ToAPI(s)
if err != nil {
return fmt.Errorf("error building api %s", err)
}

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 6833085

Please sign in to comment.