Skip to content

Commit

Permalink
chore: make api_schema required for samplegen validator (#1010)
Browse files Browse the repository at this point in the history
I found this change makes it a bit easier to implement #960.
  • Loading branch information
busunkim96 authored Oct 7, 2021
1 parent 981007d commit dbfb45a
Show file tree
Hide file tree
Showing 2 changed files with 228 additions and 184 deletions.
5 changes: 2 additions & 3 deletions gapic/samplegen/samplegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ class Validator:
("value", "field", "value_is_file", "input_parameter", "comment")
)

# TODO(dovs): make the schema a required param.
def __init__(self, method: wrappers.Method, api_schema=None):
def __init__(self, method: wrappers.Method, api_schema: api.API):
# The response ($resp) variable is special and guaranteed to exist.
self.method = method
self.request_type_ = method.input
Expand Down Expand Up @@ -1058,7 +1057,7 @@ def generate_sample(sample, api_schema, sample_template: jinja2.Template) -> str

calling_form = types.CallingForm.method_default(rpc)

v = Validator(rpc)
v = Validator(rpc, api_schema)
# Tweak some small aspects of the sample to set defaults for optional
# fields, add fields that are required for the template, and so forth.
v.preprocess_sample(sample, api_schema, rpc)
Expand Down
Loading

0 comments on commit dbfb45a

Please sign in to comment.