-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswagger.yaml
More file actions
292 lines (292 loc) · 11.3 KB
/
swagger.yaml
File metadata and controls
292 lines (292 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
swagger: "2.0"
info:
description: "An API used to generate tables in a variety of formats (html, xlsx, csv) from a json source. Also capable of parsing an html table and producing json."
version: "1.0.0"
title: "Table Renderer API"
license:
name: "Open Government Licence v3.0"
url: "http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/"
schemes:
- "http"
paths:
/render/{render_type}:
post:
summary: "Generate a table from json input"
description: "Create an html, csv or xlsx representation of the given table for display or download"
consumes:
- "application/json"
produces:
- "text/html"
- "text/csv"
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
parameters:
- name: render_type
type: string
enum: [html, csv, xlsx]
required: true
description: "The type of output required"
in: path
- name: table_definition
schema:
$ref: '#/definitions/RenderRequest'
required: true
description: "The definition of the table to be generated"
in: body
responses:
'200':
description: "An appropriate representation of the table is returned in the body"
'400':
description: "Invalid request body"
'404':
description: "Unknown render type"
'500':
$ref: '#/responses/InternalError'
/parse/html:
post:
summary: "Parse an html table and generate a json definition"
description: "A request to convert an html table (plus supporting data) into the correct RenderRequest format"
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- name: parse_request
schema:
$ref: '#/definitions/ParseRequest'
required: true
description: "Object containing the html of the table to be parsed, plus supporting information"
in: body
responses:
'200':
description: "A json representation of the table is returned in the body"
schema:
$ref: '#/definitions/ParseResponse'
'400':
description: "Invalid request body"
'500':
$ref: '#/responses/InternalError'
responses:
InternalError:
description: "Failed to process the request due to an internal error"
definitions:
RenderRequest:
description: "A definition of a table that should be rendered"
type: object
required: ["filename"]
allOf:
- $ref: '#/definitions/TableMetaData'
- type: object
properties:
row_formats:
type: array
description: "A list of format definitions for rows of the table"
items:
$ref: '#/definitions/RowFormat'
column_formats:
type: array
description: "A list of format definitions for columns of the table"
items:
$ref: '#/definitions/ColumnFormat'
cell_formats:
type: array
description: "A list of format definitions for individual cells in the table"
items:
$ref: '#/definitions/CellFormat'
data:
type: array
description: |
The content of the cells in the table (a two-dimensional array of strings).
Should contain values for each possible cell in the table,
even if that cell will be hidden because another cell has a colspan or rowspan that covers it.
items:
type: array
items:
type: string
RowFormat:
description: |
A specification that a given row should be formatted in a particular way - as a header, or with vertical alignment
type: object
properties:
row:
type: integer
description: "The index of the row this format applies to. Zero indexed."
heading:
type: boolean
description: 'Whether this row should be formatted as a heading'
height:
type: string
description: "The desired height of this row, as a valid css width property. E.g. '5em'"
vertical_align:
type: string
description: |
The vertical alignment of the row.
For html output this will be rendered as the name of a css class
that is assumed to be defined in the containing page.
enum: [Top, Middle, Bottom]
ColumnFormat:
description: |
A specification that a given column should be formatted in a particular way - as a header, or with a specific width
type: object
properties:
col:
type: integer
description: "The index of the column this format applies to. Zero indexed."
heading:
type: boolean
description: 'Whether this column should be formatted as a heading'
width:
type: string
description: "The desired width of this column, as a valid css width property. E.g. '5em'"
align:
type: string
description: |
The alignment of the column.
For html output this will be rendered as the name of a css class
that is assumed to be defined in the containing page.
enum: [Left, Center, Right, Justify]
CellFormat:
description: |
A specification that a given cell should be formatted in a particular way
- with alignment or spanning multiple columns/rows
type: object
properties:
row:
type: integer
description: "The row index of the cell this format applies to. Zero indexed."
col:
type: integer
description: "The column index of the cell this format applies to. Zero indexed."
align:
type: string
description: |
The alignment of the column.
For html output this will be rendered as the name of a css class
that is assumed to be defined in the containing page.
enum: [Left, Center, Right, Justify]
vertical_align:
type: string
description: |
The vertical alignment of the cell.
For html output this will be rendered as the name of a css class
that is assumed to be defined in the containing page.
enum: [Top, Middle, Bottom]
ParseRequest:
description: "A model for the response body when retrieving a filter output"
type: object
required: ["filename", "table_html"]
allOf:
- $ref: '#/definitions/TableMetaData'
- type: object
properties:
table_html:
type: string
description: "An html snippet containing the <table>...</table> that should be parsed"
ignore_first_row:
type: boolean
description: |
If true, the first row in the source table is ignored. Can be useful with some js spreadsheet components
that insert row and column headers.
ignore_first_column:
type: boolean
description: |
If true, the first cell of each row in the source table is ignored. Can be useful with some js spreadsheet
components that insert row and column headers.
header_rows:
type: integer
description: |
The number of rows that should be rendered as headings, after ignoring the first row (if applicable).
header_cols:
type: integer
description: |
The number of column that should be rendered as headings, after ignoring the first row (if applicable).
cell_size_units:
type: string
description: |
The desired unit for cell widths/heights. Pixel widths will be converted to this unit, provided the
required information is provided - see current_table_width and single_em_height. The default is 'auto',
in which case no table cell widths/heights will be specified.
enum: ["%", "em", "auto"]
current_table_width:
type: integer
description: |
The width of the table, used to convert pixel widths to %.
current_table_height:
type: integer
description: |
The height of the table, used to convert pixel heights to %.
single_em_height:
type: number
description: |
Used to convert height/width from pixels to em. The height of the following:
<div style="display: none; font-size: 1em; margin: 0; padding:0; height: auto; line-height: 1; border:0;">m</div>.
column_width_to_ignore:
type: string
description: |
If the source html applies a default column width that shouldn't be included in the output, specify it here.
e.g. '50px'
alignment_classes:
description: |
The names of classes that should be interpreted as defining alignment of cells. The presence of these classes
on table cells will be used to determine the align & vertical_align properties of row/column/cell formats.
$ref: '#/definitions/AlignmentClasses'
AlignmentClasses:
description: "defines the css classes that should be interpreted as defining the alignment of cells in a table"
type: object
properties:
top:
type: string
description: "The css class indicating vertical alignment at the top"
middle:
type: string
description: "The css class indicating vertical alignment in the middle"
bottom:
type: string
description: "The css class indicating vertical alignment at the bottom"
left:
type: string
description: "The css class indicating alignment on the left"
center:
type: string
description: "The css class indicating alignment in the centre"
right:
type: string
description: "The css class indicating alignment on the right"
TableMetaData:
description: "Properties that are present in both the RenderRequest and ParseRequest"
type: object
required: ["filename"]
properties:
filename:
type: string
description: "A unique id for the table"
title:
type: string
description: "The main title of the table"
subtitle:
type: string
description: "An additional title or short description of the table"
source:
type: string
description: "Where the data in the table came from"
units:
type: string
description: "Name/decription of the units used in the table, if appropriate"
keep_headers_together:
type: boolean
description: "If true, the html output includes a css class designed to prevent content of heading cells being wrapped over 2 lines. Deliberate line breaks will be honoured."
footnotes:
type: array
description: |
Notes associated with (and potentially referenced from) the table.
The order of footnotes is important, e.g. [1] will be converted into a link to the first footnote.
items:
type: string
ParseResponse:
description: "The response to a parse requests - contains an html representation of the table, and the json that defines it"
type: object
properties:
render_json:
$ref: '#/definitions/RenderRequest'
preview_html:
type: string
description: "The html of the table as it would be generated from json"