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 17, 2024
1 parent 3bd6113 commit b2f2b6a
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 28 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
run: |
./scripts/test_http_api.sh
# - name: Run script
# run: |
# ./scripts/run-api-linter.sh
- name: Run script
env:
BUF_BETA_PLUGINS_ENABLED: "1"
run: |
go install github.com/aep-dev/api-linter/cmd/buf-plugin-aep@latest
buf lint
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
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
74 changes: 57 additions & 17 deletions schema/resourcedefinition.proto
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
// resourcedefinition contains the
// schema of the resource definition.
// regenerate with
//
// protoc ./aepc/schema/resourcedefinition.proto --go_opt paths=source_relative\
// regenerate with:
// protoc ./aepc/schema/resourcedefinition.proto --go_opt paths=source_relative\
// --go_out=.
syntax = "proto3";
option go_package = "/schema";

// An API service.
message Service {
// The name of the API service.
string name = 1;

// The resources that the API service exposes.
repeated Resource resources = 2;

// These are additional objects (list of properties) that may be referenced from another property.
repeated Object objects = 3;
}

// A resource.
message Resource {
// The type of the resource. Used to programmatically
// refer to and identify the resource.
Expand All @@ -23,60 +27,96 @@ message Resource {
string plural = 2;
// The list of parent resources, referred to via the kind.
repeated string parents = 3;
// Properties
// Properties of the resource. Also often referred to as it's schema.
map<string, Property> properties = 4;
// method support
// methods support by the resource.
Methods methods = 5;
}

// An object is a collection of properties, that does not have methods of it's
// on in the API. It is currently only used as a property of a resource.
message Object {
// The name of the object.
string kind = 1;
// The properties of the object.
map<string, Property> properties = 2;
}

// Methods supported by a resource.
message Methods {
// The properties of the create method.
message CreateMethod {}
// The properties of the read method.
message ReadMethod {}
// The properties of the update method.
message UpdateMethod {}
// The properties of the delete method.
message DeleteMethod {}
// The properties of the list method.
message ListMethod {}
// THe properties of the global list method.
message GlobalListMethod {}
// THe properties of the apply method.
message ApplyMethod {}

// Specific properties of the create method for the resource.
CreateMethod create = 1;
// Specific properties of the read method for the resource.
ReadMethod read = 2;
// Specific properties of the update method for the resource.
UpdateMethod update = 3;
// Specific properties of the delete emethod for the resource.
DeleteMethod delete = 4;
// Specific properties of the list for the resource.
ListMethod list = 5;
// Specific properties of the global_list for the resource.
GlobalListMethod global_list = 6;
// Specific properties of the apply for the resource.
ApplyMethod apply = 7;
}

enum Type {
UNSPECIFIED = 0;
STRING = 1;
INT32 = 2;
INT64 = 3;
DOUBLE = 4;
FLOAT = 5;
BOOLEAN = 6;
OBJECT = 7;
ARRAY = 8;
}

// A property represents a field in a resource or object.
message Property {
// The type of the property.
Type type = 1;
// field number used for protobuf or other systems where fields must
// be explicitly enumerated.
int32 number = 2;
// true if the property is read only.
bool readOnly = 3;
// true if the property is required.
bool required = 4;

// If type is OBJECT, this is the name of the object in `messages`.
string object_type = 5;

// If type is ARRAY, these attributes will be set.
oneof array_type {
// the type of the object.
string array_object_type = 6;
// the type of the objects contained in the array.
Type array_primitive_type = 7;
}
}

// The pritimive types supported by the schema.
enum Type {
// The type is unspecified.
TYPE_UNSPECIFIED = 0;
// The type is a string.
STRING = 1;
// The type is an int32.
INT32 = 2;
// The type is an int64.
INT64 = 3;
// The type is a double.
DOUBLE = 4;
// The type is a float.
FLOAT = 5;
// The type is a boolean.
BOOLEAN = 6;
// The type is an object.
OBJECT = 7;
// The type is an array.
ARRAY = 8;
}

0 comments on commit b2f2b6a

Please sign in to comment.