Skip to content

Commit

Permalink
fix(lint): use buf plugins for lint and fixes for AEP compliance.
Browse files Browse the repository at this point in the history
Using buf plugins for linting is a more ergonomic approach, avoiding the 
need to manually clone googleapis.

Fixes to reach AEP compliance: 

- removing apply method as it is not an official AEP at the moment.
  • Loading branch information
toumorokoshi committed Sep 21, 2024
1 parent 1c6d9c0 commit 985e917
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 454 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ jobs:

- name: "test: no change to generated files."
run: |
go install github.com/bufbuild/buf/cmd/buf@v1.38.0
go install github.com/bufbuild/buf/cmd/buf@v1.42.0
./scripts/verify-goldens.sh
- name: "test: example server function"
run: |
./scripts/test_http_api.sh
# - name: Run script
# run: |
# ./scripts/run-api-linter.sh
- name: run api-linter
run: |
go install github.com/aep-dev/api-linter/cmd/buf-plugin-aep@latest
buf lint --path example/bookstore/v1/bookstore.proto
8 changes: 3 additions & 5 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Generated by buf. DO NOT EDIT.
version: v1
version: v2
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
- name: buf.build/googleapis/googleapis
commit: 28151c0d0a1641bf938a7672c500e01d
digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de
digest: b5:93b70089baa4fc05a92d3e52db91a4b7812db3b57b9664f6cb301733938cb630e377a938e8a56779388171c749c1d42a2e9a6c6230f2ff45f127a8102a6a27d0
6 changes: 4 additions & 2 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
version: v1
version: v2
breaking:
use:
- FILE
lint:
use:
- DEFAULT
- AEP
plugins:
- plugin: buf-plugin-aep
deps:
- buf.build/googleapis/googleapis:28151c0d0a1641bf938a7672c500e01d
211 changes: 61 additions & 150 deletions example/bookstore/v1/bookstore.pb.go

Large diffs are not rendered by default.

119 changes: 0 additions & 119 deletions example/bookstore/v1/bookstore.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions example/bookstore/v1/bookstore.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ service Bookstore {

option (google.api.method_signature) = "parent";
}

// An aep-compliant Apply method for books.
rpc ApplyBook ( ApplyBookRequest ) returns ( Book ) {
option (google.api.http) = { put: "/{path=books/*}", body: "book" };
}
}

// A Book resource.
Expand Down Expand Up @@ -151,15 +146,3 @@ message ListBookResponse {
// The page token indicating the ending point of this response.
string next_page_token = 10011;
}

// Request message for the ApplyBook method
message ApplyBookRequest {
// The globally unique identifier for the resource
string path = 10018 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = { type: "bookstore.example.com/Book" }
];

// The resource to perform the operation on.
Book book = 10015 [(google.api.field_behavior) = REQUIRED];
}
43 changes: 0 additions & 43 deletions example/bookstore/v1/bookstore.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,49 +178,6 @@
"Bookstore"
]
},
"put": {
"summary": "An aep-compliant Apply method for books.",
"operationId": "Bookstore_ApplyBook",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1Book"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "path",
"description": "The globally unique identifier for the resource",
"in": "path",
"required": true,
"type": "string",
"pattern": "books/[^/]+"
},
{
"name": "book",
"description": "The resource to perform the operation on.",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1Book",
"required": [
"book"
]
}
}
],
"tags": [
"Bookstore"
]
},
"patch": {
"summary": "An aep-compliant Update method for Book.",
"operationId": "Bookstore_UpdateBook",
Expand Down
2 changes: 1 addition & 1 deletion example/bookstore/v1/bookstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resources:
update: {}
delete: {}
list: {}
apply: {}
# apply: {} # do not uncomment until there is an AEP on apply.
# - kind: "Publisher"
# plural: "publishers"
# methods:
Expand Down
39 changes: 0 additions & 39 deletions example/bookstore/v1/bookstore_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions example/bookstore/v1/bookstore_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,6 @@
}
}
]
},
"put": {
"responses": {
"200": {
"schema": {
"$ref": "#/definitions/Book"
}
}
},
"parameters": [
{
"in": "body",
"name": "body",
"schema": {
"$ref": "#/definitions/Book"
}
}
]
}
}
},
Expand Down
Loading

0 comments on commit 985e917

Please sign in to comment.