open_api-loader 0.0.1

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.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +15 -0
  3. data/.gitignore +13 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +28 -0
  6. data/.travis.yml +24 -0
  7. data/CHANGELOG.md +10 -0
  8. data/Gemfile +8 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +99 -0
  11. data/Rakefile +10 -0
  12. data/bin/console +6 -0
  13. data/bin/setup +6 -0
  14. data/lib/open_api-loader.rb +1 -0
  15. data/lib/open_api/loader.rb +44 -0
  16. data/lib/open_api/loader/collector.rb +61 -0
  17. data/lib/open_api/loader/denormalizer.rb +27 -0
  18. data/lib/open_api/loader/denormalizer/parameters.rb +46 -0
  19. data/lib/open_api/loader/denormalizer/security.rb +35 -0
  20. data/lib/open_api/loader/denormalizer/servers.rb +36 -0
  21. data/lib/open_api/loader/denormalizer/variables.rb +54 -0
  22. data/lib/open_api/loader/reader.rb +47 -0
  23. data/lib/open_api/loader/ref.rb +85 -0
  24. data/lib/open_api/loader/translator.rb +50 -0
  25. data/lib/open_api/loader/translator/clean_definitions.rb +16 -0
  26. data/lib/open_api/loader/translator/convert_bodies.rb +77 -0
  27. data/lib/open_api/loader/translator/convert_forms.rb +71 -0
  28. data/lib/open_api/loader/translator/convert_parameters.rb +135 -0
  29. data/lib/open_api/loader/translator/convert_responses.rb +63 -0
  30. data/lib/open_api/loader/translator/convert_security_schemes.rb +49 -0
  31. data/lib/open_api/loader/translator/convert_servers.rb +46 -0
  32. data/lib/open_api/loader/translator/convert_version.rb +12 -0
  33. data/lib/open_api/loader/translator/denormalize_consumes.rb +44 -0
  34. data/lib/open_api/loader/translator/denormalize_parameters.rb +55 -0
  35. data/lib/open_api/loader/translator/denormalize_produces.rb +53 -0
  36. data/open_api-loader.gemspec +25 -0
  37. data/spec/fixtures/oas2/collected.yaml +1012 -0
  38. data/spec/fixtures/oas2/denormalized.yaml +1462 -0
  39. data/spec/fixtures/oas2/loaded.yaml +564 -0
  40. data/spec/fixtures/oas2/models.yaml +118 -0
  41. data/spec/fixtures/oas2/source.json +1 -0
  42. data/spec/fixtures/oas2/source.yaml +569 -0
  43. data/spec/fixtures/oas2/translated.yaml +1396 -0
  44. data/spec/fixtures/oas3/collected.yaml +233 -0
  45. data/spec/fixtures/oas3/denormalized.yaml +233 -0
  46. data/spec/fixtures/oas3/source.json +1 -0
  47. data/spec/fixtures/oas3/source.yaml +217 -0
  48. data/spec/loader_spec.rb +53 -0
  49. data/spec/spec_helper.rb +17 -0
  50. data/spec/support/fixture_helpers.rb +18 -0
  51. data/spec/support/path_helpers.rb +27 -0
  52. data/spec/unit/collector_spec.rb +31 -0
  53. data/spec/unit/denormalizer_spec.rb +17 -0
  54. data/spec/unit/reader_spec.rb +53 -0
  55. data/spec/unit/ref_spec.rb +107 -0
  56. data/spec/unit/translator_spec.rb +15 -0
  57. metadata +232 -0
@@ -0,0 +1,233 @@
1
+ ---
2
+ openapi: 3.0.0
3
+ servers:
4
+ - url: '{scheme}://developer.uspto.gov/ds-api'
5
+ variables:
6
+ scheme:
7
+ description: 'The Data Set API is accessible via https and http'
8
+ enum:
9
+ - 'https'
10
+ - 'http'
11
+ default: 'https'
12
+ info:
13
+ description: >-
14
+ The Data Set API (DSAPI) allows the public users to discover and search
15
+ USPTO exported data sets. This is a generic API that allows USPTO users to
16
+ make any CSV based data files searchable through API. With the help of GET
17
+ call, it returns the list of data fields that are searchable. With the help
18
+ of POST call, data can be fetched based on the filters on the field names.
19
+ Please note that POST call is used to search the actual data. The reason for
20
+ the POST call is that it allows users to specify any complex search criteria
21
+ without worry about the GET size limitations as well as encoding of the
22
+ input parameters.
23
+ version: 1.0.0
24
+ title: USPTO Data Set API
25
+ contact:
26
+ name: Open Data Portal
27
+ url: 'https://developer.uspto.gov'
28
+ email: developer@uspto.gov
29
+ tags:
30
+ - name: metadata
31
+ description: Find out about the data sets
32
+ - name: search
33
+ description: Search a data set
34
+ paths:
35
+ /:
36
+ get:
37
+ tags:
38
+ - metadata
39
+ operationId: list-data-sets
40
+ summary: List available data sets
41
+ responses:
42
+ "200":
43
+ description: Returns a list of data sets
44
+ content:
45
+ application/json:
46
+ schema:
47
+ type: object
48
+ properties:
49
+ total:
50
+ type: integer
51
+ apis:
52
+ type: array
53
+ items:
54
+ type: object
55
+ properties:
56
+ apiKey:
57
+ type: string
58
+ description: To be used as a dataset parameter value
59
+ apiVersionNumber:
60
+ type: string
61
+ description: To be used as a version parameter value
62
+ apiUrl:
63
+ type: string
64
+ format: uriref
65
+ description: "The URL describing the dataset's fields"
66
+ apiDocumentationUrl:
67
+ type: string
68
+ format: uriref
69
+ description: A URL to the API console for each API
70
+ example:
71
+ {
72
+ "total": 2,
73
+ "apis": [
74
+ {
75
+ "apiKey": "oa_citations",
76
+ "apiVersionNumber": "v1",
77
+ "apiUrl": "https://developer.uspto.gov/ds-api/oa_citations/v1/fields",
78
+ "apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/oa_citations.json"
79
+ },
80
+ {
81
+ "apiKey": "cancer_moonshot",
82
+ "apiVersionNumber": "v1",
83
+ "apiUrl": "https://developer.uspto.gov/ds-api/cancer_moonshot/v1/fields",
84
+ "apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/cancer_moonshot.json"
85
+ }
86
+ ]
87
+ }
88
+ /{dataset}/{version}/fields:
89
+ parameters:
90
+ - name: dataset
91
+ in: path
92
+ description: 'Name of the dataset. In this case, the default value is oa_citations'
93
+ required: true
94
+ schema:
95
+ type: string
96
+ default: oa_citations
97
+ - name: version
98
+ in: path
99
+ description: Version of the dataset.
100
+ required: true
101
+ schema:
102
+ type: string
103
+ default: v1
104
+ get:
105
+ tags:
106
+ - metadata
107
+ summary: >-
108
+ Provides the general information about the API and the list of fields
109
+ that can be used to query the dataset.
110
+ description: >-
111
+ This GET API returns the list of all the searchable field names that are
112
+ in the oa_citations. Please see the 'fields' attribute which returns an
113
+ array of field names. Each field or a combination of fields can be
114
+ searched using the syntax options shown below.
115
+ operationId: list-searchable-fields
116
+ responses:
117
+ "200":
118
+ description: >-
119
+ The dataset api for the given version is found and it is accessible
120
+ to consume.
121
+ content:
122
+ application/json:
123
+ schema:
124
+ type: string
125
+ "404":
126
+ description: >-
127
+ The combination of dataset name and version is not found in the
128
+ system or it is not published yet to be consumed by public.
129
+ content:
130
+ application/json:
131
+ schema:
132
+ type: string
133
+ /{dataset}/{version}/records:
134
+ parameters:
135
+ - name: version
136
+ in: path
137
+ description: Version of the dataset.
138
+ required: true
139
+ schema:
140
+ type: string
141
+ default: v1
142
+ - name: dataset
143
+ in: path
144
+ description: 'Name of the dataset. In this case, the default value is oa_citations'
145
+ required: true
146
+ schema:
147
+ type: string
148
+ default: oa_citations
149
+ post:
150
+ tags:
151
+ - search
152
+ summary: >-
153
+ Provides search capability for the data set with the given search
154
+ criteria.
155
+ description: >-
156
+ This API is based on Solr/Lucense Search. The data is indexed using
157
+ SOLR. This GET API returns the list of all the searchable field names
158
+ that are in the Solr Index. Please see the 'fields' attribute which
159
+ returns an array of field names. Each field or a combination of fields
160
+ can be searched using the Solr/Lucene Syntax. Please refer
161
+ https://lucene.apache.org/core/3_6_2/queryparsersyntax.html#Overview for
162
+ the query syntax. List of field names that are searchable can be
163
+ determined using above GET api.
164
+ operationId: perform-search
165
+ responses:
166
+ "200":
167
+ description: successful operation
168
+ content:
169
+ application/json:
170
+ schema:
171
+ type: array
172
+ items:
173
+ type: object
174
+ additionalProperties:
175
+ type: object
176
+ "404":
177
+ description: No matching record found for the given criteria.
178
+ requestBody:
179
+ content:
180
+ application/x-www-form-urlencoded:
181
+ schema:
182
+ type: object
183
+ properties:
184
+ criteria:
185
+ description: >-
186
+ Uses Lucene Query Syntax in the format of
187
+ propertyName:value, propertyName:[num1 TO num2] and date
188
+ range format: propertyName:[yyyyMMdd TO yyyyMMdd]. In the
189
+ response please see the 'docs' element which has the list of
190
+ record objects. Each record structure would consist of all
191
+ the fields and their corresponding values.
192
+ type: string
193
+ default: '*:*'
194
+ start:
195
+ description: Starting record number. Default value is 0.
196
+ type: integer
197
+ default: 0
198
+ rows:
199
+ description: >-
200
+ Specify number of rows to be returned. If you run the search
201
+ with default values, in the response you will see 'numFound'
202
+ attribute which will tell the number of records available in
203
+ the dataset.
204
+ type: integer
205
+ default: 100
206
+ required:
207
+ - criteria
208
+ components:
209
+ schemas:
210
+ dataSetList:
211
+ type: object
212
+ properties:
213
+ total:
214
+ type: integer
215
+ apis:
216
+ type: array
217
+ items:
218
+ type: object
219
+ properties:
220
+ apiKey:
221
+ type: string
222
+ description: To be used as a dataset parameter value
223
+ apiVersionNumber:
224
+ type: string
225
+ description: To be used as a version parameter value
226
+ apiUrl:
227
+ type: string
228
+ format: uriref
229
+ description: "The URL describing the dataset's fields"
230
+ apiDocumentationUrl:
231
+ type: string
232
+ format: uriref
233
+ description: A URL to the API console for each API
@@ -0,0 +1,233 @@
1
+ ---
2
+ openapi: 3.0.0
3
+ info:
4
+ description: >-
5
+ The Data Set API (DSAPI) allows the public users to discover and search
6
+ USPTO exported data sets. This is a generic API that allows USPTO users to
7
+ make any CSV based data files searchable through API. With the help of GET
8
+ call, it returns the list of data fields that are searchable. With the help
9
+ of POST call, data can be fetched based on the filters on the field names.
10
+ Please note that POST call is used to search the actual data. The reason for
11
+ the POST call is that it allows users to specify any complex search criteria
12
+ without worry about the GET size limitations as well as encoding of the
13
+ input parameters.
14
+ version: 1.0.0
15
+ title: USPTO Data Set API
16
+ contact:
17
+ name: Open Data Portal
18
+ url: https://developer.uspto.gov
19
+ email: developer@uspto.gov
20
+ tags:
21
+ - name: metadata
22
+ description: Find out about the data sets
23
+ - name: search
24
+ description: Search a data set
25
+ paths:
26
+ /:
27
+ get:
28
+ tags:
29
+ - metadata
30
+ operationId: list-data-sets
31
+ summary: List available data sets
32
+ servers:
33
+ - url: https://developer.uspto.gov/ds-api
34
+ - url: http://developer.uspto.gov/ds-api
35
+ responses:
36
+ "200":
37
+ description: Returns a list of data sets
38
+ content:
39
+ application/json:
40
+ schema:
41
+ type: object
42
+ properties:
43
+ total:
44
+ type: integer
45
+ apis:
46
+ type: array
47
+ items:
48
+ type: object
49
+ properties:
50
+ apiKey:
51
+ type: string
52
+ description: To be used as a dataset parameter value
53
+ apiVersionNumber:
54
+ type: string
55
+ description: To be used as a version parameter value
56
+ apiUrl:
57
+ type: string
58
+ format: uriref
59
+ description: "The URL describing the dataset's fields"
60
+ apiDocumentationUrl:
61
+ type: string
62
+ format: uriref
63
+ description: A URL to the API console for each API
64
+ example:
65
+ {
66
+ "total": 2,
67
+ "apis": [
68
+ {
69
+ "apiKey": "oa_citations",
70
+ "apiVersionNumber": "v1",
71
+ "apiUrl": "https://developer.uspto.gov/ds-api/oa_citations/v1/fields",
72
+ "apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/oa_citations.json"
73
+ },
74
+ {
75
+ "apiKey": "cancer_moonshot",
76
+ "apiVersionNumber": "v1",
77
+ "apiUrl": "https://developer.uspto.gov/ds-api/cancer_moonshot/v1/fields",
78
+ "apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/cancer_moonshot.json"
79
+ }
80
+ ]
81
+ }
82
+ /{dataset}/{version}/fields:
83
+ get:
84
+ tags:
85
+ - metadata
86
+ summary: >-
87
+ Provides the general information about the API and the list of fields
88
+ that can be used to query the dataset.
89
+ description: >-
90
+ This GET API returns the list of all the searchable field names that are
91
+ in the oa_citations. Please see the 'fields' attribute which returns an
92
+ array of field names. Each field or a combination of fields can be
93
+ searched using the syntax options shown below.
94
+ operationId: list-searchable-fields
95
+ servers:
96
+ - url: https://developer.uspto.gov/ds-api
97
+ - url: http://developer.uspto.gov/ds-api
98
+ parameters:
99
+ - name: dataset
100
+ in: path
101
+ description: 'Name of the dataset. In this case, the default value is oa_citations'
102
+ required: true
103
+ schema:
104
+ type: string
105
+ default: oa_citations
106
+ - name: version
107
+ in: path
108
+ description: Version of the dataset.
109
+ required: true
110
+ schema:
111
+ type: string
112
+ default: v1
113
+ responses:
114
+ "200":
115
+ description: >-
116
+ The dataset api for the given version is found and it is accessible
117
+ to consume.
118
+ content:
119
+ application/json:
120
+ schema:
121
+ type: string
122
+ "404":
123
+ description: >-
124
+ The combination of dataset name and version is not found in the
125
+ system or it is not published yet to be consumed by public.
126
+ content:
127
+ application/json:
128
+ schema:
129
+ type: string
130
+ /{dataset}/{version}/records:
131
+ post:
132
+ tags:
133
+ - search
134
+ summary: >-
135
+ Provides search capability for the data set with the given search
136
+ criteria.
137
+ description: >-
138
+ This API is based on Solr/Lucense Search. The data is indexed using
139
+ SOLR. This GET API returns the list of all the searchable field names
140
+ that are in the Solr Index. Please see the 'fields' attribute which
141
+ returns an array of field names. Each field or a combination of fields
142
+ can be searched using the Solr/Lucene Syntax. Please refer
143
+ https://lucene.apache.org/core/3_6_2/queryparsersyntax.html#Overview for
144
+ the query syntax. List of field names that are searchable can be
145
+ determined using above GET api.
146
+ operationId: perform-search
147
+ servers:
148
+ - url: https://developer.uspto.gov/ds-api
149
+ - url: http://developer.uspto.gov/ds-api
150
+ parameters:
151
+ - name: version
152
+ in: path
153
+ description: Version of the dataset.
154
+ required: true
155
+ schema:
156
+ type: string
157
+ default: v1
158
+ - name: dataset
159
+ in: path
160
+ description: 'Name of the dataset. In this case, the default value is oa_citations'
161
+ required: true
162
+ schema:
163
+ type: string
164
+ default: oa_citations
165
+ responses:
166
+ "200":
167
+ description: successful operation
168
+ content:
169
+ application/json:
170
+ schema:
171
+ type: array
172
+ items:
173
+ type: object
174
+ additionalProperties:
175
+ type: object
176
+ "404":
177
+ description: No matching record found for the given criteria.
178
+ requestBody:
179
+ content:
180
+ application/x-www-form-urlencoded:
181
+ schema:
182
+ type: object
183
+ properties:
184
+ criteria:
185
+ description: >-
186
+ Uses Lucene Query Syntax in the format of
187
+ propertyName:value, propertyName:[num1 TO num2] and date
188
+ range format: propertyName:[yyyyMMdd TO yyyyMMdd]. In the
189
+ response please see the 'docs' element which has the list of
190
+ record objects. Each record structure would consist of all
191
+ the fields and their corresponding values.
192
+ type: string
193
+ default: '*:*'
194
+ start:
195
+ description: Starting record number. Default value is 0.
196
+ type: integer
197
+ default: 0
198
+ rows:
199
+ description: >-
200
+ Specify number of rows to be returned. If you run the search
201
+ with default values, in the response you will see 'numFound'
202
+ attribute which will tell the number of records available in
203
+ the dataset.
204
+ type: integer
205
+ default: 100
206
+ required:
207
+ - criteria
208
+ components:
209
+ schemas:
210
+ dataSetList:
211
+ type: object
212
+ properties:
213
+ total:
214
+ type: integer
215
+ apis:
216
+ type: array
217
+ items:
218
+ type: object
219
+ properties:
220
+ apiKey:
221
+ type: string
222
+ description: To be used as a dataset parameter value
223
+ apiVersionNumber:
224
+ type: string
225
+ description: To be used as a version parameter value
226
+ apiUrl:
227
+ type: string
228
+ format: uriref
229
+ description: "The URL describing the dataset's fields"
230
+ apiDocumentationUrl:
231
+ type: string
232
+ format: uriref
233
+ description: A URL to the API console for each API