diff --git a/python/server/auto_generated/qgsserverogcapi.sip.in b/python/server/auto_generated/qgsserverogcapi.sip.in index 1894fe26ae1..b9c139f03b1 100644 --- a/python/server/auto_generated/qgsserverogcapi.sip.in +++ b/python/server/auto_generated/qgsserverogcapi.sip.in @@ -55,7 +55,8 @@ as instances of QgsServerOgcApiHandler. GEOJSON, OPENAPI3, JSON, - HTML + HTML, + XML }; QgsServerOgcApi( QgsServerInterface *serverIface, diff --git a/src/server/qgsserverogcapi.cpp b/src/server/qgsserverogcapi.cpp index 1bc06910e79..c39ce058856 100644 --- a/src/server/qgsserverogcapi.cpp +++ b/src/server/qgsserverogcapi.cpp @@ -33,6 +33,7 @@ QMap QgsServerOgcApi::sContentTypeMim }; map[QgsServerOgcApi::ContentType::HTML] = QStringList { QStringLiteral( "text/html" ) }; map[QgsServerOgcApi::ContentType::OPENAPI3] = QStringList { QStringLiteral( "application/openapi+json;version=3.0" ) }; + map[QgsServerOgcApi::ContentType::XML] = QStringList { QStringLiteral( "application/xml" ) }; return map; }(); diff --git a/src/server/qgsserverogcapi.h b/src/server/qgsserverogcapi.h index 2f78309f4c6..95bbabf51dc 100644 --- a/src/server/qgsserverogcapi.h +++ b/src/server/qgsserverogcapi.h @@ -72,7 +72,8 @@ class SERVER_EXPORT QgsServerOgcApi : public QgsServerApi GEOJSON, OPENAPI3, //! "application/openapi+json;version=3.0" JSON, - HTML + HTML, + XML }; Q_ENUM( ContentType ) diff --git a/src/server/qgsserverogcapihandler.cpp b/src/server/qgsserverogcapihandler.cpp index e3e1d19e9dd..e1394b6e022 100644 --- a/src/server/qgsserverogcapihandler.cpp +++ b/src/server/qgsserverogcapihandler.cpp @@ -122,6 +122,9 @@ void QgsServerOgcApiHandler::write( json &data, const QgsServerApiContext &conte case QgsServerOgcApi::ContentType::OPENAPI3: jsonDump( data, context, QgsServerOgcApi::contentTypeMimes().value( contentType ).first() ); break; + case QgsServerOgcApi::ContentType::XML: + // Not handled yet + break; } } @@ -512,6 +515,11 @@ QString QgsServerOgcApiHandler::parentLink( const QUrl &url, int levels ) qi.push_back( i ); } } + // Make sure the parent link ends with a slash + if ( ! path.endsWith( '/' ) ) + { + path.append( '/' ); + } result.setQueryItems( qi ); result.setPath( path ); return result.toString(); diff --git a/src/server/services/wfs3/qgswfs3handlers.cpp b/src/server/services/wfs3/qgswfs3handlers.cpp index afea557d3ed..e32a7cf8074 100644 --- a/src/server/services/wfs3/qgswfs3handlers.cpp +++ b/src/server/services/wfs3/qgswfs3handlers.cpp @@ -637,16 +637,22 @@ void QgsWfs3DescribeCollectionHandler::handleRequest( const QgsServerApiContext { "rel", QgsServerOgcApi::relToString( QgsServerOgcApi::Rel::items ) }, { "type", QgsServerOgcApi::mimeType( QgsServerOgcApi::ContentType::HTML ) }, { "title", title } - } - /* TODO: not sure what these "concepts" are about, neither if they are mandatory - ,{ - { "href", href( api, *context.request() , QStringLiteral( "/concepts" ), QStringLiteral( "html") ) }, - { "rel", QgsServerOgcApi::relToString( QgsServerOgcApi::Rel::item ) }, - { "type", "text/html" }, - { "title", "Describe " + title } - } - */ - ); + } ); + + linksList.push_back( + { + { + "href", parentLink( context.request()->url(), 3 ).toStdString() + + "?request=DescribeFeatureType&typenames=" + + QUrlQuery( shortName ).toString( QUrl::EncodeSpaces ).toStdString() + + "&service=WFS&version=2.0" + }, + { "rel", QgsServerOgcApi::relToString( QgsServerOgcApi::Rel::describedBy ) }, + { "type", QgsServerOgcApi::mimeType( QgsServerOgcApi::ContentType::XML ) }, + { "title", "Schema for " + title } + } ); + + json crss = json::array(); for ( const auto &crs : QgsServerApiUtils::publishedCrsList( context.project() ) ) { diff --git a/tests/testdata/qgis_server/api/test_wfs3_api_project.json b/tests/testdata/qgis_server/api/test_wfs3_api_project.json index 5013f2e3409..82a52b0781a 100644 --- a/tests/testdata/qgis_server/api/test_wfs3_api_project.json +++ b/tests/testdata/qgis_server/api/test_wfs3_api_project.json @@ -1466,7 +1466,7 @@ Content-Type: application/openapi+json;version=3.0 }, "servers": [ { - "url": "http://server.qgis.org/wfs3" + "url": "http://server.qgis.org/wfs3/" } ], "tags": [ @@ -1478,5 +1478,6 @@ Content-Type: application/openapi+json;version=3.0 "description": "Access to data (features).", "name": "Features" } - ] + ], + "timeStamp": "2019-07-05T12:27:07Z" } \ No newline at end of file diff --git a/tests/testdata/qgis_server/api/test_wfs3_collection_points_timefilters.json b/tests/testdata/qgis_server/api/test_wfs3_collection_points_timefilters.json index 5481d7fb7de..b81c66f697e 100644 --- a/tests/testdata/qgis_server/api/test_wfs3_collection_points_timefilters.json +++ b/tests/testdata/qgis_server/api/test_wfs3_collection_points_timefilters.json @@ -53,8 +53,14 @@ Content-Type: application/json "rel": "items", "title": "points", "type": "text/html" + }, + { + "href": "http://server.qgis.org/?request=DescribeFeatureType&typenames=points&service=WFS&version=2.0", + "rel": "describedBy", + "title": "Schema for points", + "type": "application/xml" } ], - "timeStamp": "2019-10-20T16:29:01Z", + "timeStamp": "2019-07-05T12:27:07Z", "title": "points" } \ No newline at end of file diff --git a/tests/testdata/qgis_server/api/test_wfs3_collection_testlayer_èé.html b/tests/testdata/qgis_server/api/test_wfs3_collection_testlayer_èé.html index db7d419df8f..3a70c2c0aa0 100644 --- a/tests/testdata/qgis_server/api/test_wfs3_collection_testlayer_èé.html +++ b/tests/testdata/qgis_server/api/test_wfs3_collection_testlayer_èé.html @@ -26,9 +26,9 @@