webspicy 0.27.1 → 0.27.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/webspicy/tester/result/error_schema_met.rb +3 -1
 - data/lib/webspicy/version.rb +1 -1
 - data/lib/webspicy/web/formaldoc.fio +1 -0
 - data/lib/webspicy/web/openapi/data_struct.rb +1 -1
 - data/lib/webspicy/web/openapi/reporter.rb +13 -2
 - data/lib/webspicy/web/openapi/utils.rb +46 -14
 - data/lib/webspicy/web/specification/test_case.rb +5 -0
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: ce82bd72f4fe8bb69cde7146e59f55e2164c643af4431b248b7d0ba5728caf82
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f27a2c3cc31f327105d0a397a03fab97ed05831f122a857b4e168ff2bb901627
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 64050f5982d11d77c296ee96bef3d6ef593be7f22dde89534dfc8e4cc793eb21266df450b8d7ec72fa48dbd7e2473334e306ab9f1dec180746140c9ba1cd7011
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 13d582ea7921160f0dab7df43d73b63782a902c16c15ce11d8e8a46495a7608692c9620c88559e86351b239a2f57fedc718b2811568fc709bae3b272eba1ae2e
         
     | 
    
        data/lib/webspicy/version.rb
    CHANGED
    
    
| 
         @@ -16,17 +16,28 @@ module Webspicy 
     | 
|
| 
       16 
16 
     | 
    
         
             
                    def after_each
         
     | 
| 
       17 
17 
     | 
    
         
             
                      @datastruct.ensure_tags(tags_for(specification))
         
     | 
| 
       18 
18 
     | 
    
         
             
                      @datastruct.ensure_path(base_path_for(specification))
         
     | 
| 
       19 
     | 
    
         
            -
                      @datastruct.ensure_path(base_verb_for( 
     | 
| 
      
 19 
     | 
    
         
            +
                      @datastruct.ensure_path(base_verb_for(test_case))
         
     | 
| 
       20 
20 
     | 
    
         
             
                      @datastruct.ensure_path(base_request_body_for(service))
         
     | 
| 
       21 
21 
     | 
    
         
             
                      @datastruct.ensure_path(base_request_example_for(test_case))
         
     | 
| 
       22 
22 
     | 
    
         
             
                      @datastruct.ensure_path(base_request_response_for(invocation))
         
     | 
| 
       23 
23 
     | 
    
         
             
                    end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                    def report
         
     | 
| 
       26 
     | 
    
         
            -
                      json =  
     | 
| 
      
 26 
     | 
    
         
            +
                      json = DataStruct::MERGER.deep_merge(
         
     | 
| 
       27 
27 
     | 
    
         
             
                        @base,
         
     | 
| 
       28 
28 
     | 
    
         
             
                        @datastruct.to_openapi_data,
         
     | 
| 
       29 
29 
     | 
    
         
             
                      )
         
     | 
| 
      
 30 
     | 
    
         
            +
                      order = ["get", "post", "patch", "delete"]
         
     | 
| 
      
 31 
     | 
    
         
            +
                      json["paths"].keys.each do |path|
         
     | 
| 
      
 32 
     | 
    
         
            +
                        sorted = {}
         
     | 
| 
      
 33 
     | 
    
         
            +
                        json["paths"][path]
         
     | 
| 
      
 34 
     | 
    
         
            +
                          .keys
         
     | 
| 
      
 35 
     | 
    
         
            +
                          .sort_by{|k| order.index(k) || -1 }
         
     | 
| 
      
 36 
     | 
    
         
            +
                          .each do |k|
         
     | 
| 
      
 37 
     | 
    
         
            +
                            sorted[k] = json["paths"][path][k]
         
     | 
| 
      
 38 
     | 
    
         
            +
                          end
         
     | 
| 
      
 39 
     | 
    
         
            +
                        json["paths"][path] = sorted
         
     | 
| 
      
 40 
     | 
    
         
            +
                      end
         
     | 
| 
       30 
41 
     | 
    
         
             
                      @output_file.write(JSON.pretty_generate(json))
         
     | 
| 
       31 
42 
     | 
    
         
             
                    end
         
     | 
| 
       32 
43 
     | 
    
         | 
| 
         @@ -36,12 +36,13 @@ module Webspicy 
     | 
|
| 
       36 
36 
     | 
    
         
             
                      })
         
     | 
| 
       37 
37 
     | 
    
         
             
                    end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
                    def base_verb_for( 
     | 
| 
      
 39 
     | 
    
         
            +
                    def base_verb_for(test_case)
         
     | 
| 
      
 40 
     | 
    
         
            +
                      service = test_case.service
         
     | 
| 
       40 
41 
     | 
    
         
             
                      verb_defn = {
         
     | 
| 
       41 
42 
     | 
    
         
             
                        summary: service.name,
         
     | 
| 
       42 
43 
     | 
    
         
             
                        description: service.description,
         
     | 
| 
       43 
44 
     | 
    
         
             
                        tags: tags_for(service.specification).map{|s| s[:name] },
         
     | 
| 
       44 
     | 
    
         
            -
                        parameters: parameters_for(service),
         
     | 
| 
      
 45 
     | 
    
         
            +
                        parameters: parameters_for(service, test_case),
         
     | 
| 
       45 
46 
     | 
    
         
             
                      }
         
     | 
| 
       46 
47 
     | 
    
         | 
| 
       47 
48 
     | 
    
         
             
                      verb_defn = service.conditions.inject(verb_defn) do |memo, p|
         
     | 
| 
         @@ -61,7 +62,6 @@ module Webspicy 
     | 
|
| 
       61 
62 
     | 
    
         | 
| 
       62 
63 
     | 
    
         
             
                      schema = actual_body_schema(service)
         
     | 
| 
       63 
64 
     | 
    
         
             
                      return nil if empty_schema?(schema)
         
     | 
| 
       64 
     | 
    
         
            -
                      puts schema.inspect
         
     | 
| 
       65 
65 
     | 
    
         | 
| 
       66 
66 
     | 
    
         
             
                      content_type = content_type_for(service)
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
         @@ -120,7 +120,12 @@ module Webspicy 
     | 
|
| 
       120 
120 
     | 
    
         
             
                        content = {
         
     | 
| 
       121 
121 
     | 
    
         
             
                          content_type => {
         
     | 
| 
       122 
122 
     | 
    
         
             
                            schema: schema&.to_json_schema,
         
     | 
| 
       123 
     | 
    
         
            -
                             
     | 
| 
      
 123 
     | 
    
         
            +
                            examples: {
         
     | 
| 
      
 124 
     | 
    
         
            +
                              test_case.description => {
         
     | 
| 
      
 125 
     | 
    
         
            +
                                description: test_case.description,
         
     | 
| 
      
 126 
     | 
    
         
            +
                                value: example,
         
     | 
| 
      
 127 
     | 
    
         
            +
                              },
         
     | 
| 
      
 128 
     | 
    
         
            +
                            },
         
     | 
| 
       124 
129 
     | 
    
         
             
                          }.compact
         
     | 
| 
       125 
130 
     | 
    
         
             
                        }
         
     | 
| 
       126 
131 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -144,17 +149,31 @@ module Webspicy 
     | 
|
| 
       144 
149 
     | 
    
         
             
                      }]
         
     | 
| 
       145 
150 
     | 
    
         
             
                    end
         
     | 
| 
       146 
151 
     | 
    
         | 
| 
       147 
     | 
    
         
            -
                    def parameters_for(service)
         
     | 
| 
       148 
     | 
    
         
            -
                      schema =  
     | 
| 
       149 
     | 
    
         
            -
                       
     | 
| 
       150 
     | 
    
         
            -
                         
     | 
| 
       151 
     | 
    
         
            -
                           
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
      
 152 
     | 
    
         
            +
                    def parameters_for(service, test_case)
         
     | 
| 
      
 153 
     | 
    
         
            +
                      schema = actual_parameters_schema(service)
         
     | 
| 
      
 154 
     | 
    
         
            +
                      if schema.is_a?(Finitio::HashBasedType)
         
     | 
| 
      
 155 
     | 
    
         
            +
                        schema.heading.map do |attr|
         
     | 
| 
      
 156 
     | 
    
         
            +
                          {
         
     | 
| 
      
 157 
     | 
    
         
            +
                            in: 'path',
         
     | 
| 
      
 158 
     | 
    
         
            +
                            name: attr.name,
         
     | 
| 
      
 159 
     | 
    
         
            +
                            description: attr.metadata[:description],
         
     | 
| 
      
 160 
     | 
    
         
            +
                            schema: attr.to_json_schema,
         
     | 
| 
      
 161 
     | 
    
         
            +
                            required: true,
         
     | 
| 
      
 162 
     | 
    
         
            +
                            example: test_case.params[attr.name.to_s]
         
     | 
| 
      
 163 
     | 
    
         
            +
                          }.compact
         
     | 
| 
      
 164 
     | 
    
         
            +
                        end
         
     | 
| 
      
 165 
     | 
    
         
            +
                      else
         
     | 
| 
      
 166 
     | 
    
         
            +
                        params = service.specification.url_placeholders.map{|p|
         
     | 
| 
      
 167 
     | 
    
         
            +
                          {
         
     | 
| 
      
 168 
     | 
    
         
            +
                            in: 'path',
         
     | 
| 
      
 169 
     | 
    
         
            +
                            name: p,
         
     | 
| 
      
 170 
     | 
    
         
            +
                            schema: { type: 'string' },
         
     | 
| 
      
 171 
     | 
    
         
            +
                            required: true,
         
     | 
| 
      
 172 
     | 
    
         
            +
                            example: test_case.params[attr.name.to_s]
         
     | 
| 
      
 173 
     | 
    
         
            +
                          }
         
     | 
| 
       155 
174 
     | 
    
         
             
                        }
         
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
                       
     | 
| 
      
 175 
     | 
    
         
            +
                        params.empty? ? nil : params
         
     | 
| 
      
 176 
     | 
    
         
            +
                      end
         
     | 
| 
       158 
177 
     | 
    
         
             
                    end
         
     | 
| 
       159 
178 
     | 
    
         | 
| 
       160 
179 
     | 
    
         
             
                    def actual_output_schema(test_case, counterexample)
         
     | 
| 
         @@ -169,6 +188,19 @@ module Webspicy 
     | 
|
| 
       169 
188 
     | 
    
         
             
                      service.input_schema['Main']
         
     | 
| 
       170 
189 
     | 
    
         
             
                    end
         
     | 
| 
       171 
190 
     | 
    
         | 
| 
      
 191 
     | 
    
         
            +
                    def actual_parameters_schema(service)
         
     | 
| 
      
 192 
     | 
    
         
            +
                      schema = actual_input_schema(service)
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
                      a_schema = schema
         
     | 
| 
      
 195 
     | 
    
         
            +
                      a_schema = schema.target if schema.is_a?(Finitio::AliasType)
         
     | 
| 
      
 196 
     | 
    
         
            +
                      return schema unless a_schema.is_a?(Finitio::HashBasedType)
         
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
      
 198 
     | 
    
         
            +
                      in_url = service.specification.url_placeholders.map(&:to_sym)
         
     | 
| 
      
 199 
     | 
    
         
            +
                      return schema if in_url.empty?
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
                      a_schema.project(in_url)
         
     | 
| 
      
 202 
     | 
    
         
            +
                    end
         
     | 
| 
      
 203 
     | 
    
         
            +
             
     | 
| 
       172 
204 
     | 
    
         
             
                    def actual_body_schema(service)
         
     | 
| 
       173 
205 
     | 
    
         
             
                      schema = actual_input_schema(service)
         
     | 
| 
       174 
206 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: webspicy
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.27. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.27.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Bernard Lambeau
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2025-03- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2025-03-28 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rake
         
     |