• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

notEthan / scorpio / 23019784647

12 Mar 2026 07:22PM UTC coverage: 87.508% (+0.008%) from 87.5%
23019784647

push

github

notEthan
Merge branches 'dev644' and '070' into HEAD

1366 of 1561 relevant lines covered (87.51%)

5347.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.38
/lib/scorpio/google_api_document.rb
1
# frozen_string_literal: true
2

3
module Scorpio
18✔
4
  module Google
18✔
5
    discovery_rest_description_doc = YAML.safe_load(Scorpio.root.join('documents/www.googleapis.com/discovery/v1/apis/discovery/v1/rest.yml').read)
18✔
6
    DISCOVERY_REST_DESCRIPTION = JSI.new_metaschema_node(
18✔
7
      discovery_rest_description_doc,
8
      dialect: JSI::Schema::Draft04::DIALECT,
9
      metaschema_root_ref: "#/schemas/JsonSchema",
10
      root_schema_ref: "#/schemas/RestDescription",
11
    )
12

13
    # naming these is not strictly necessary, but is nice to have.
14

15

16
    DirectoryList = DISCOVERY_REST_DESCRIPTION.schemas['DirectoryList'].jsi_schema_module
18✔
17
    JsonSchema     = DISCOVERY_REST_DESCRIPTION.schemas['JsonSchema'].jsi_schema_module
18✔
18
    RestDescription = DISCOVERY_REST_DESCRIPTION.schemas['RestDescription'].jsi_schema_module
18✔
19
    RestMethod     = DISCOVERY_REST_DESCRIPTION.schemas['RestMethod'].jsi_schema_module
18✔
20
    RestResource  = DISCOVERY_REST_DESCRIPTION.schemas['RestResource'].jsi_schema_module
18✔
21

22
    module RestDescription
18✔
23
      Resources = properties['resources']
18✔
24
    end
25

26
    module RestMethod
18✔
27
      Request = properties['request']
18✔
28
      Response = properties['response']
18✔
29

30
      # these only contain a $ref to a schema, but that is enough to use them as schemas
31
      Request.schema.describes_schema!([JSI::Schema::Draft04])
18✔
32
      Response.schema.describes_schema!([JSI::Schema::Draft04])
18✔
33
    end
34

35
    module HasMethodsAndResources
18✔
36
      def operations
18✔
37
        return @operations if instance_variable_defined?(:@operations)
×
38
        @operations = OpenAPI::OperationsScope.new(each_operation)
×
39
      end
40

41
      def each_operation(&block)
18✔
42
        return(to_enum(__method__)) unless block
×
43

44
        (self['methods'] || {}).each_value(&block)
×
45

46
        (self['resources'] || {}).each_value do |resource|
×
47
          resource.each_operation(&block)
×
48
        end
49
      end
50
    end
51

52
    module RestDescription
18✔
53
      include(OpenAPI::Document)
18✔
54
      include(HasMethodsAndResources)
18✔
55

56
      attr_writer(:base_url)
18✔
57

58
      def base_url(scheme: nil, server: nil, server_variables: nil)
18✔
59
        return @base_url if instance_variable_defined?(:@base_url)
×
60
        JSI::Util.uri(rootUrl ? File.join(rootUrl, servicePath) : baseUrl) # baseUrl is deprecated
×
61
      end
62

63
      def title
18✔
64
        self['title'] # override OpenAPI::Document#title
×
65
      end
66
    end
67

68
    module RestResource
18✔
69
      include(HasMethodsAndResources)
18✔
70
    end
71

72
    module RestMethod
18✔
73
      include(OpenAPI::Operation)
18✔
74

75
      def tagged?(tag_name)
18✔
76
        resource_names.include?(tag_name)
×
77
      end
78

79
      def resource_names
18✔
80
        # resource name is the property name where a RestResource is. kind of hax but it works.
81
        jsi_parent_nodes.select { |n| n.is_a?(RestResource) }.map { |r| r.jsi_ptr.tokens.last }
×
82
      end
83

84
      def path_template_str
18✔
85
        path
×
86
      end
87

88
      def parameters
18✔
89
        (self['parameters'] || {}).map do |name, schema|
×
90
          param = {'name' => name}
×
91
          param['in'] = schema.location if schema.key?('location')
×
92
          param['schema'] = schema
×
93
          #param['description'] = schema.description if schema.key?('description')
94
          #param['required'] = schema.required if schema.key?('required')
95
          param
×
96
        end
97
      end
98

99
      def request_media_type
18✔
100
        'application/json'
×
101
      end
102

103
      def http_method
18✔
104
        httpMethod
×
105
      end
106

107
      def openapi_document
18✔
108
        rest_description
×
109
      end
110

111
      def rest_description
18✔
112
        jsi_parent_nodes.detect { |p| p.is_a?(RestDescription) }
×
113
      end
114

115
      def scheme
18✔
116
        nil
117
      end
118

119
      def server
18✔
120
        nil
121
      end
122

123
      def server_variables
18✔
124
        nil
125
      end
126

127
      def operationId
18✔
128
        id
×
129
      end
130

131
      # @param media_type unused
132
      def request_schema(media_type: nil)
18✔
133
        request
×
134
      end
135

136
      def request_schemas
18✔
137
        request ? [request] : []
×
138
      end
139

140
      def response_schema(status: nil, media_type: nil)
18✔
141
        response
×
142
      end
143

144
      def response_schemas
18✔
145
        response ? [response] : []
×
146
      end
147
    end
148
  end
149
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc