diff --git a/PxWeb/Controllers/Api2/TableApiController.cs b/PxWeb/Controllers/Api2/TableApiController.cs
index dbc64cb1..8e34032d 100644
--- a/PxWeb/Controllers/Api2/TableApiController.cs
+++ b/PxWeb/Controllers/Api2/TableApiController.cs
@@ -63,13 +63,11 @@ public TableApiController(IDataSource dataSource, ILanguageHelper languageHelper
_selectionResponseMapper = selectionResponseMapper;
}
-
- public override IActionResult GetMetadataById([FromRoute(Name = "id"), Required] string id, [FromQuery(Name = "lang")] string? lang)
+ public override IActionResult GetMetadataById([FromRoute(Name = "id"), Required] string id, [FromQuery(Name = "lang")] string? lang, [FromQuery(Name = "outputFormat")] MetadataOutputFormatType? outputFormat)
{
lang = _languageHelper.HandleLanguage(lang);
IPXModelBuilder? builder = _dataSource.CreateBuilder(id, lang);
-
if (builder != null)
{
try
@@ -77,9 +75,15 @@ public override IActionResult GetMetadataById([FromRoute(Name = "id"), Required]
builder.BuildForSelection();
var model = builder.Model;
- TableMetadataResponse tm = _tableMetadataResponseMapper.Map(model, id, lang);
-
- return new ObjectResult(tm);
+ if (outputFormat != null && outputFormat == MetadataOutputFormatType.Stat2Enum)
+ {
+ throw new NotImplementedException();
+ }
+ else
+ {
+ TableMetadataResponse tm = _tableMetadataResponseMapper.Map(model, id, lang);
+ return new ObjectResult(tm);
+ }
}
catch (Exception)
{
@@ -295,6 +299,7 @@ public override IActionResult GetDefaultSelection([FromRoute(Name = "id"), Requi
}
+
}
}
diff --git a/PxWeb/Properties/launchSettings.json b/PxWeb/Properties/launchSettings.json
index 3a885fd1..6838d525 100644
--- a/PxWeb/Properties/launchSettings.json
+++ b/PxWeb/Properties/launchSettings.json
@@ -8,7 +8,7 @@
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger/",
- "applicationUrl": "https://localhost:5001;http://localhost:5000",
+ "applicationUrl": "https://localhost:8443;http://localhost:8080",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
diff --git a/PxWeb/PxWeb.csproj b/PxWeb/PxWeb.csproj
index 062c4b5a..2276e776 100644
--- a/PxWeb/PxWeb.csproj
+++ b/PxWeb/PxWeb.csproj
@@ -39,7 +39,7 @@
-
+
diff --git a/PxWeb/wwwroot/swagger-original.json b/PxWeb/wwwroot/swagger-original.json
deleted file mode 100644
index a9c8292f..00000000
--- a/PxWeb/wwwroot/swagger-original.json
+++ /dev/null
@@ -1,454 +0,0 @@
-{
- "openapi" : "3.0.2",
- "info" : {
- "title" : "PxApi",
- "version" : "2.0"
- },
- "servers" : [ {
- "url" : "https://api.server.test/v1"
- } ],
- "paths" : {
- "/navigation" : {
- "get" : {
- "tags" : [ "Navigation" ],
- "summary" : "Browse the database structure",
- "operationId" : "GetNavigationRoot",
- "parameters" : [ {
- "name" : "lang",
- "in" : "query",
- "description" : "The language if the default is not what you want.",
- "required" : false,
- "style" : "form",
- "explode" : true,
- "schema" : {
- "type" : "string"
- },
- "examples" : {
- "X1" : {
- "summary" : "For english",
- "value" : "en"
- },
- "X2" : {
- "summary" : "For danish",
- "value" : "dk"
- }
- }
- } ],
- "responses" : {
- "200" : {
- "description" : "Success",
- "content" : {
- "application/json" : {
- "schema" : {
- "$ref" : "#/components/schemas/NavigationItem"
- },
- "examples" : {
- "NavigateRoot" : {
- "$ref" : "#/components/examples/navigation-root"
- }
- }
- }
- }
- },
- "429" : {
- "description" : "Error respsone for 429",
- "content" : {
- "application/problem+json" : {
- "schema" : {
- "$ref" : "#/components/schemas/Problem"
- },
- "example" : {
- "title" : "Too many requests",
- "status" : 429,
- "detail" : "You have reach the threshold for request limiting. 30 request per minute."
- }
- }
- }
- }
- }
- }
- },
- "/navigation/{id}" : {
- "get" : {
- "tags" : [ "Navigation" ],
- "summary" : "Gets navigation item with the given id.",
- "operationId" : "GetNavigationById",
- "parameters" : [ {
- "name" : "id",
- "in" : "path",
- "description" : "Id",
- "required" : true,
- "style" : "simple",
- "explode" : false,
- "schema" : {
- "type" : "string"
- }
- }, {
- "name" : "lang",
- "in" : "query",
- "description" : "The language if the default is not what you want.",
- "required" : false,
- "style" : "form",
- "explode" : true,
- "schema" : {
- "type" : "string"
- },
- "examples" : {
- "X1" : {
- "summary" : "For english",
- "value" : "en"
- },
- "X2" : {
- "summary" : "For danish",
- "value" : "dk"
- }
- }
- } ],
- "responses" : {
- "200" : {
- "description" : "Success",
- "content" : {
- "application/json" : {
- "schema" : {
- "$ref" : "#/components/schemas/NavigationItem"
- },
- "examples" : {
- "Navigation-BE" : {
- "$ref" : "#/components/examples/navigation-be"
- }
- }
- }
- }
- }
- }
- }
- }
- },
- "components" : {
- "schemas" : {
- "NavigationItem" : {
- "type" : "object",
- "properties" : {
- "id" : {
- "type" : "string",
- "nullable" : true
- },
- "objectType" : {
- "type" : "string",
- "description" : "One of heading, table, folder or folder-information",
- "nullable" : false
- },
- "label" : {
- "type" : "string",
- "description" : "Display text",
- "nullable" : true
- },
- "description" : {
- "type" : "string",
- "description" : "Longer text describing node.",
- "nullable" : true
- }
- },
- "description" : "Navigation item.",
- "example" : {
- "description" : "description",
- "id" : "id",
- "label" : "label",
- "objectType" : "objectType"
- }
- },
- "Folder" : {
- "allOf" : [ {
- "$ref" : "#/components/schemas/NavigationItem"
- }, {
- "type" : "object",
- "properties" : {
- "tags" : {
- "type" : "array",
- "nullable" : true,
- "items" : {
- "type" : "string",
- "description" : "tag for folder"
- }
- },
- "folderContents" : {
- "type" : "array",
- "nullable" : true,
- "items" : {
- "$ref" : "#/components/schemas/NavigationItem"
- }
- },
- "links" : {
- "type" : "array",
- "description" : "Links to ...",
- "nullable" : true,
- "items" : {
- "$ref" : "#/components/schemas/Link"
- }
- }
- },
- "description" : "Folder item"
- } ]
- },
- "FolderInformation" : {
- "allOf" : [ {
- "$ref" : "#/components/schemas/NavigationItem"
- }, {
- "type" : "object",
- "properties" : {
- "tags" : {
- "type" : "array",
- "nullable" : true,
- "items" : {
- "type" : "string",
- "description" : "tag for folder"
- }
- },
- "links" : {
- "type" : "array",
- "description" : "Links to ...",
- "nullable" : true,
- "items" : {
- "$ref" : "#/components/schemas/Link"
- }
- }
- },
- "description" : "Folder information item"
- } ]
- },
- "Heading" : {
- "allOf" : [ {
- "$ref" : "#/components/schemas/NavigationItem"
- }, {
- "type" : "object",
- "description" : "Heading item"
- } ]
- },
- "Table" : {
- "allOf" : [ {
- "$ref" : "#/components/schemas/NavigationItem"
- }, {
- "type" : "object",
- "properties" : {
- "tags" : {
- "type" : "array",
- "nullable" : true,
- "items" : {
- "type" : "string",
- "description" : "tag for table"
- }
- },
- "updated" : {
- "type" : "string",
- "description" : "For treeNodeType \"table\"",
- "format" : "date-time",
- "nullable" : true
- },
- "category" : {
- "type" : "string",
- "description" : "Mostly for internal use. Which category table belongs to. internal, official, private or section. I, O, P, S",
- "enum" : [ "internal", "official", "private", "section" ],
- "default" : "official"
- },
- "links" : {
- "type" : "array",
- "description" : "Links to ...",
- "nullable" : true,
- "items" : {
- "$ref" : "#/components/schemas/Link"
- }
- }
- },
- "description" : "Table item"
- } ]
- },
- "Link" : {
- "required" : [ "href", "rel" ],
- "type" : "object",
- "properties" : {
- "rel" : {
- "type" : "string",
- "nullable" : false
- },
- "href" : {
- "type" : "string",
- "nullable" : false
- }
- },
- "additionalProperties" : false
- },
- "Problem" : {
- "type" : "object",
- "properties" : {
- "type" : {
- "type" : "string",
- "description" : "An absolute URI that identifies the problem type. When dereferenced,\nit SHOULD provide human-readable documentation for the problem type\n(e.g., using HTML).\n",
- "format" : "uri",
- "example" : "https://zalando.github.io/problem/constraint-violation",
- "default" : "about:blank"
- },
- "title" : {
- "type" : "string",
- "description" : "A short, summary of the problem type. Written in english and readable\nfor engineers (usually not suited for non technical stakeholders and\nnot localized); example: Service Unavailable\n"
- },
- "status" : {
- "maximum" : 600,
- "exclusiveMaximum" : true,
- "minimum" : 100,
- "type" : "integer",
- "description" : "The HTTP status code generated by the origin server for this occurrence\nof the problem.\n",
- "format" : "int32",
- "example" : 503
- },
- "detail" : {
- "type" : "string",
- "description" : "A human readable explanation specific to this occurrence of the\nproblem.\n",
- "example" : "Connection to database timed out"
- },
- "instance" : {
- "type" : "string",
- "description" : "An absolute URI that identifies the specific occurrence of the problem.\nIt may or may not yield further information if dereferenced.\n",
- "format" : "uri"
- }
- }
- }
- },
- "responses" : {
- "ErrorResponse429" : {
- "description" : "Error respsone for 429",
- "content" : {
- "application/problem+json" : {
- "schema" : {
- "$ref" : "#/components/schemas/Problem"
- },
- "example" : {
- "title" : "Too many requests",
- "status" : 429,
- "detail" : "You have reach the threshold for request limiting. 30 request per minute."
- }
- }
- }
- }
- },
- "parameters" : {
- "language" : {
- "name" : "lang",
- "in" : "query",
- "description" : "The language if the default is not what you want.",
- "required" : false,
- "style" : "form",
- "explode" : true,
- "schema" : {
- "type" : "string"
- },
- "examples" : {
- "X1" : {
- "summary" : "For english",
- "value" : "en"
- },
- "X2" : {
- "summary" : "For danish",
- "value" : "dk"
- }
- }
- },
- "id" : {
- "name" : "id",
- "in" : "path",
- "description" : "Id",
- "required" : true,
- "style" : "simple",
- "explode" : false,
- "schema" : {
- "type" : "string"
- }
- }
- },
- "examples" : {
- "navigation-root" : {
- "description" : "Example for 200 response for navigation endpoint",
- "value" : {
- "objectType" : "folder",
- "links" : [ {
- "rel" : "self",
- "href" : "https://my-site.com/api/v2/navigation"
- } ],
- "folderContents" : [ {
- "id" : "AM",
- "objectType" : "folder",
- "label" : "Arbetsmarknad",
- "description" : "Beskrivning av arbetsmarknad",
- "links" : [ {
- "rel" : "self",
- "href" : "https://my-site.com/api/v2/navigation/AM"
- } ]
- }, {
- "id" : "BE",
- "objectType" : "folder",
- "label" : "Befolkning",
- "description" : "Folkmängd, in- och utvanding, medellivslängd, namn, prognoser mm",
- "links" : [ {
- "rel" : "self",
- "href" : "https://my-site.com/api/v2/navigation/BE"
- } ]
- } ]
- }
- },
- "navigation-be" : {
- "description" : "Example for 200 response for navigation endpoint",
- "value" : {
- "id" : "BE",
- "objectType" : "folder",
- "label" : "Befolkning",
- "description" : "Folkmängd, in- och utvanding, medellivslängd, namn, prognoser mm",
- "links" : [ {
- "rel" : "self",
- "href" : "https://my-site.com/api/v2/navigation/BE"
- } ],
- "folderContents" : [ {
- "id" : "BE0101",
- "objectType" : "folder-information",
- "label" : "Befolkningsstatistik",
- "description" : "Folkmängd, in- och utvanding, medellivslängd, namn, prognoser mm",
- "links" : [ {
- "rel" : "folder",
- "href" : "https://my-site.com/api/v2/navigation/BE0101"
- } ]
- }, {
- "id" : "BE0401",
- "objectType" : "folder-information",
- "label" : "Befolkningsframskrivningar",
- "description" : "Folkmängd, in- och utvanding, medellivslängd, namn, prognoser mm",
- "links" : [ {
- "rel" : "folder",
- "href" : "https://my-site.com/api/v2/navigation/BE0401"
- } ]
- }, {
- "id" : "BEH1",
- "objectType" : "heading",
- "label" : "Intressanta siffror",
- "description" : "XYZ"
- }, {
- "id" : "TAB0001",
- "objectType" : "table",
- "label" : "Tabell A",
- "description" : "Folkmängd, in- och utvanding, medellivslängd, namn, prognoser mm",
- "updated" : "",
- "categoy" : "",
- "tags" : [ ],
- "links" : [ {
- "rel" : "self",
- "href" : "https://my-site.com/api/v2/tables/TAB0001"
- }, {
- "rel" : "metadata",
- "href" : "https://my-site.com/api/v2/tables/TAB0001/metadata"
- }, {
- "rel" : "data",
- "href" : "https://my-site.com/api/v2/tables/TAB0001/data"
- } ]
- } ]
- }
- }
- }
- }
-}
diff --git a/PxWebApi.BigTests/TableController/TableApiControllerTest.cs b/PxWebApi.BigTests/TableController/TableApiControllerTest.cs
index b84f2638..bb88a107 100644
--- a/PxWebApi.BigTests/TableController/TableApiControllerTest.cs
+++ b/PxWebApi.BigTests/TableController/TableApiControllerTest.cs
@@ -58,7 +58,7 @@ public void GetMetadataById()
{
PxWeb.Controllers.Api2.TableApiController tac = GetController();
- var result = tac.GetMetadataById("TAB004", null);
+ var result = tac.GetMetadataById("TAB004", null, null);
var actual = result.ToJSON(false);
var expected = "{\"Value\":{\"language\":\"en\",\"id\":\"TAB004\",\"label\":\"Total air emissions by sector, greenhouse gas, contents and year\",\"aggregationAllowed\":false,\"officialStatistics\":false,\"subjectCode\":\"EN\",\"subjectLabel\":\"Environment\",\"source\":\"Statistics Sweden\",\"license\":\"https://creativecommons.org/share-your-work/public-domain/cc0/\",\"updated\":\"2023-05-25T13:42:00Z\",\"notes\":[{\"mandatory\":false,\"text\":\"Footnote text\"},{\"mandatory\":false,\"text\":\".. = Data not available\"}],\"contacts\":[{\"raw\":\"Test Testsson, SCB#Tel: 08-111 222 33#Fax: 08-222 333 44#E-mail: test.testsson@scb.se\"},{\"raw\":\"Test2 Testsson2, SCB#Tel: 08-333 444 55#Fax: 08-444 555 66#E-mail: test2.testsson2@scb.se\"}],\"variables\":[{\"elimination\":false,\"values\":[{\"code\":\"0.1\",\"label\":\"NATIONAL TOTAL (excluding LULUCF, excluding international transports)\"},{\"code\":\"0.2\",\"label\":\"NATIONAL TOTAL (excluding LULUCF, including international transports)\"},{\"code\":\"0.3\",\"label\":\"NATIONAL TOTAL (including LULUCF, excluding international transports)\"},{\"code\":\"0.4\",\"label\":\"NATIONAL TOTAL (including LULUCF, including international transports)\"},{\"code\":\"1.0\",\"label\":\"OFF-ROAD VEHICLES AND OTHER MACHINERY, TOTAL\"},{\"code\":\"10.0\",\"label\":\"LAND-USE, LAND-USE CHANGE AND FORESTRY (LULUCF), TOTAL\"},{\"code\":\"2.0\",\"label\":\"WASTE, TOTAL\"},{\"code\":\"3.0\",\"label\":\"ELECTRICITY AND DISTRICT HEATING, TOTAL\"},{\"code\":\"4.0\",\"label\":\"INDUSTRY, TOTAL\"},{\"code\":\"5.0\",\"label\":\"INTERNATIONAL TRANSPORT, TOTAL\"},{\"code\":\"6.0\",\"label\":\"AGRICULTURE, TOTAL\"},{\"code\":\"7.0\",\"label\":\"SOLVENT USE AND OTHER PRODUCT USE, TOTAL\"},{\"code\":\"8.0\",\"label\":\"DOMESTIC TRANSPORT, TOTAL\"},{\"code\":\"9.0\",\"label\":\"HEATING OF HOUSES AND PREMISES, TOTAL\"}],\"id\":\"SECTOR\",\"label\":\"sector\",\"type\":\"RegularVariable\",\"notes\":[{\"mandatory\":false,\"text\":\"Footnote text\"}]},{\"elimination\":false,\"values\":[{\"code\":\"CH4\",\"label\":\"Methane (CH4) (t)\"},{\"code\":\"CH4_CO2-ekv.\",\"label\":\"Methane (CH4) (kt CO2-eqv.)\"},{\"code\":\"CO2\",\"label\":\"Carbon Dioxide (CO2) (kt)\"},{\"code\":\"CO2-BIO\",\"label\":\"Biogenic carbon dioxide (CO2) from fuels (kt)\"},{\"code\":\"CO2-ekv.\",\"label\":\"Total Greenhouse Gases (kt CO2-eqv.)\"},{\"code\":\"HFC\",\"label\":\"Hydrofluorocarbons (HFCs) (kt CO2-eqv.)\"},{\"code\":\"N2O\",\"label\":\"Nitrous Oxide (N2O) (t)\"},{\"code\":\"N2O_CO2-ekv.\",\"label\":\"Nitrous Oxide (N2O) (kt CO2-eqv.)\"},{\"code\":\"PFC\",\"label\":\"Perfluorocarbons (PFCs) (kt CO2-eqv.)\"},{\"code\":\"SF6\",\"label\":\"Sulphur Hexafluoride (SF6) (kg)\"},{\"code\":\"SF6_CO2-ekv.\",\"label\":\"Sulphur Hexafluoride (SF6) (kt CO2-eqv.)\",\"notes\":[{\"mandatory\":false,\"text\":\"Footnote text\"}]}],\"id\":\"GREENHOUSEGAS\",\"label\":\"greenhouse gas\",\"type\":\"RegularVariable\"},{\"values\":[{\"adjustment\":\"None\",\"measuringType\":\"Stock\",\"preferedNumberOfDecimals\":0,\"priceType\":\"Undefined\",\"unit\":\"Device varies with the subject\",\"code\":\"Emission\",\"label\":\"Substance\"}],\"id\":\"ContentsCode\",\"label\":\"contents\",\"type\":\"ContentsVariable\"},{\"timeUnit\":\"Annual\",\"firstPeriod\":\"1990\",\"lastPeriod\":\"2017\",\"values\":[{\"code\":\"1990\",\"label\":\"1990\"},{\"code\":\"1991\",\"label\":\"1991\"},{\"code\":\"1992\",\"label\":\"1992\"},{\"code\":\"1993\",\"label\":\"1993\"},{\"code\":\"1994\",\"label\":\"1994\"},{\"code\":\"1995\",\"label\":\"1995\"},{\"code\":\"1996\",\"label\":\"1996\"},{\"code\":\"1997\",\"label\":\"1997\"},{\"code\":\"1998\",\"label\":\"1998\"},{\"code\":\"1999\",\"label\":\"1999\"},{\"code\":\"2000\",\"label\":\"2000\"},{\"code\":\"2001\",\"label\":\"2001\"},{\"code\":\"2002\",\"label\":\"2002\"},{\"code\":\"2003\",\"label\":\"2003\"},{\"code\":\"2004\",\"label\":\"2004\"},{\"code\":\"2005\",\"label\":\"2005\"},{\"code\":\"2006\",\"label\":\"2006\"},{\"code\":\"2007\",\"label\":\"2007\"},{\"code\":\"2008\",\"label\":\"2008\"},{\"code\":\"2009\",\"label\":\"2009\"},{\"code\":\"2010\",\"label\":\"2010\"},{\"code\":\"2011\",\"label\":\"2011\"},{\"code\":\"2012\",\"label\":\"2012\"},{\"code\":\"2013\",\"label\":\"2013\"},{\"code\":\"2014\",\"label\":\"2014\"},{\"code\":\"2015\",\"label\":\"2015\"},{\"code\":\"2016\",\"label\":\"2016\"},{\"code\":\"2017\",\"label\":\"2017\"}],\"id\":\"TIME\",\"label\":\"year\",\"type\":\"TimeVariable\"}],\"links\":[{\"rel\":\"self\",\"hreflang\":\"en\",\"href\":\"https://www.pxapi.com/api/v2/tables/TAB004/metadata?lang=en\"},{\"rel\":\"data\",\"hreflang\":\"en\",\"href\":\"https://www.pxapi.com/api/v2/tables/TAB004/data?lang=en\"}]},\"Formatters\":[],\"ContentTypes\":[]}";
diff --git a/README.md b/README.md
index dc5a7256..32ed5f35 100644
--- a/README.md
+++ b/README.md
@@ -9,9 +9,9 @@ We are currently developing PxWebApi 2.0
## Development notes
```sh
-curl -i -H "API_ADMIN_KEY: test" -X 'PUT' https://localhost:5001/api/v2/admin/database
-curl -i -H "API_ADMIN_KEY: test" -X 'POST' https://localhost:5001/api/v2/admin/searchindex
-curl -i -H "API_ADMIN_KEY: test" -X 'PATCH' -H 'Content-Type: application/json' -d '["TAB001", "TAB004"]' https://localhost:5001/api/v2/admin/searchindex
+curl -i -H "API_ADMIN_KEY: test" -X 'PUT' https://localhost:8443/api/v2/admin/database
+curl -i -H "API_ADMIN_KEY: test" -X 'POST' https://localhost:8443/api/v2/admin/searchindex
+curl -i -H "API_ADMIN_KEY: test" -X 'PATCH' -H 'Content-Type: application/json' -d '["TAB001", "TAB004"]' https://localhost:8443/api/v2/admin/searchindex
```
### Code formatting