-
Notifications
You must be signed in to change notification settings - Fork 871
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Introduce api_version to discovery clients (#18969)
- Loading branch information
1 parent
0f19a58
commit b8caede
Showing
6 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'google/apis/discovery_v1' | ||
|
||
# Extend the DiscoveryV1 API classes with additional fields for code generation, | ||
# supporting features which are not present in the schema itself. | ||
unless Google::Apis::DiscoveryV1::RestMethod.method_defined? :api_version | ||
module Google | ||
module Apis | ||
module DiscoveryV1 | ||
class RestMethod | ||
# The `apiVersion` for this method, or empty if not present. | ||
# @return [String] | ||
attr_accessor :api_version | ||
|
||
# @private | ||
# The original DiscoveryV1::RestMethod `update!` method to be called | ||
# after applying patches to this schema. | ||
alias_method :update_discovery!, :update! | ||
|
||
# Update properties of this object. | ||
def update!(**args) | ||
@api_version = args.key?(:api_version) ? args[:api_version] : "" | ||
update_discovery!(**args) | ||
end | ||
|
||
# @private | ||
class Representation | ||
# @private | ||
# The api_version based on the JSON key value. | ||
property :api_version, as: 'apiVersion' | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
google-apis-generator/spec/google/apis/generator/patch_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'spec_helper' | ||
require 'google/apis/generator' | ||
|
||
RSpec.describe 'Google::Apis::Generator with DiscoveryV1 patch' do | ||
|
||
it 'should modify RestMethod if `api_version` is not defined' do | ||
expect(Google::Apis::Generator::Discovery::RestMethod.method_defined? :update_discovery!).to eql(true) | ||
end | ||
end |