From 0b287e96f6d50a262c027237c25c6731218ab393 Mon Sep 17 00:00:00 2001 From: Aaron Tye Date: Sat, 6 Jul 2024 17:17:00 -0400 Subject: [PATCH] Omit empty values and update yaml (#98) * update * fix openapi --------- Co-authored-by: atye --- internal/entrypoint/static/dist/openapi.yaml | 34 ++++++++++++++------ pkg/client/format.go | 4 +-- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/internal/entrypoint/static/dist/openapi.yaml b/internal/entrypoint/static/dist/openapi.yaml index 3506291..3f6d990 100644 --- a/internal/entrypoint/static/dist/openapi.yaml +++ b/internal/entrypoint/static/dist/openapi.yaml @@ -5,29 +5,40 @@ info: description: | [https://github.com/atye/wikitable2json](https://github.com/atye/wikitable2json/) - - Tables with the HTML class `wikitable`, `standard`, and `toccolours` are returned - If you are making automated requests, set a unique `User-Agent` header with an email address or URL contact page per the [Wikimedia REST API](https://en.wikipedia.org/api/rest_v1/) - ## Examples: - +
+ ### Get all tables on page [Arhaan_Khan](https://en.wikipedia.org/wiki/Arhaan_Khan) in the default matrix format: [https://www.wikitable2json.com/api/Arhaan_Khan](https://www.wikitable2json.com/api/Arhaan_Khan) +
+ ### Get the first and second tables on page [Arhaan_Khan](https://en.wikipedia.org/wiki/Arhaan_Khan) in the default matrix format: [https://www.wikitable2json.com/api/Arhaan_Khan?table=1&table=2](https://www.wikitable2json.com/api/Arhaan_Khan?table=1&table=2) +
+ ### Get the second table on page [Arhaan_Khan](https://en.wikipedia.org/wiki/Arhaan_Khan) in a key-value format using the first row as keys: [https://www.wikitable2json.com/api/Arhaan_Khan?table=1&keyRows=1](https://www.wikitable2json.com/api/Arhaan_Khan?table=1&keyRows=1) +
+ ### Get the second table on page [Arhaan_Khan](https://en.wikipedia.org/wiki/Arhaan_Khan) in a key-value format with verbose output using the first row as keys: [https://www.wikitable2json.com/api/Arhaan_Khan?table=1&keyRows=1&verbose=true](https://www.wikitable2json.com/api/Arhaan_Khan?table=1&keyRows=1&verbose=true) +
+ ### Get the second table on page [1970–71_Chester_F.C._season](https://en.wikipedia.org/wiki/1970–71_Chester_F.C._season) in a key-value format using the first two rows as key: [https://www.wikitable2json.com/api/1970–71_Chester_F.C._season?table=1&keyRows=2](https://www.wikitable2json.com/api/1970–71_Chester_F.C._season?table=1&keyRows=2) +
+ ### Get all tables on German page [Liste_der_Baudenkmäler_in_Feucht](https://de.wikipedia.org/wiki/Liste_der_Baudenkmäler_in_Feucht) in the default matrix format: [https://www.wikitable2json.com/api/Liste_der_Baudenkmäler_in_Feucht?lang=de](https://www.wikitable2json.com/api/Liste_der_Baudenkmäler_in_Feucht?lang=de) +
+ ### Get all tables on page [Template:COVID-19_pandemic_data](https://en.wikipedia.org/wiki/Template:COVID-19_pandemic_data) with reference link text removed: [https://www.wikitable2json.com/api/Template:COVID-19_pandemic_data?cleanRef=true](https://www.wikitable2json.com/api/Template:COVID-19_pandemic_data?cleanRef=true) paths: @@ -120,9 +131,7 @@ components: items: type: array items: - type: object - additionalProperties: - type: string + $ref: '#/components/schemas/verboseCell' keyValue: description: | List of tables in the key-value format with the keys being the first x rows specified in the keyRows query
@@ -132,9 +141,7 @@ components: items: type: object additionalProperties: - type: object - additionalProperties: - type: string + type: string keyValueVerbose: description: | List of tables in the key-value format with the keys being the first x rows specified in the keyRows query with verbose output
@@ -144,6 +151,15 @@ components: items: type: object additionalProperties: + $ref: '#/components/schemas/verboseCell' + verboseCell: + type: object + properties: + text: + type: string + links: + type: array + items: type: string error: description: Error schema with a message, status code, and any details diff --git a/pkg/client/format.go b/pkg/client/format.go index 0e4ff6b..5d901ed 100644 --- a/pkg/client/format.go +++ b/pkg/client/format.go @@ -12,8 +12,8 @@ import ( type parsed map[int]map[int]cell type Verbose struct { - Text string `json:"text"` - Links []string `json:"links"` + Text string `json:"text,omitempty"` + Links []string `json:"links,omitempty"` } var (