mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
Hide real name string args from schema and messages
This commit is contained in:
parent
e747ffede0
commit
904a120282
@ -98,6 +98,23 @@ Returns the name of the parameter
|
||||
void setDescription( const QString &description );
|
||||
%Docstring
|
||||
Sets validator ``description``
|
||||
%End
|
||||
|
||||
bool hidden() const;
|
||||
%Docstring
|
||||
Returns ``True`` if the parameter is hidden from the schema.
|
||||
|
||||
Hidden params can be useful to implement legacy parameters or
|
||||
parameters that can be accepted without being advertised.
|
||||
|
||||
.. versionadded:: 3.28
|
||||
%End
|
||||
|
||||
void setHidden( bool hidden );
|
||||
%Docstring
|
||||
Set the parameter's ``hidden`` status, parametes are not hidden by default.
|
||||
|
||||
.. versionadded:: 3.28
|
||||
%End
|
||||
|
||||
};
|
||||
|
@ -159,3 +159,13 @@ void QgsServerQueryStringParameter::setDescription( const QString &description )
|
||||
{
|
||||
mDescription = description;
|
||||
}
|
||||
|
||||
bool QgsServerQueryStringParameter::hidden() const
|
||||
{
|
||||
return mHidden;
|
||||
}
|
||||
|
||||
void QgsServerQueryStringParameter::setHidden( bool hidden )
|
||||
{
|
||||
mHidden = hidden;
|
||||
}
|
||||
|
@ -140,6 +140,23 @@ class SERVER_EXPORT QgsServerQueryStringParameter
|
||||
*/
|
||||
void setDescription( const QString &description );
|
||||
|
||||
/**
|
||||
* Returns TRUE if the parameter is hidden from the schema.
|
||||
*
|
||||
* Hidden params can be useful to implement legacy parameters or
|
||||
* parameters that can be accepted without being advertised.
|
||||
*
|
||||
* \since QGIS 3.28
|
||||
*/
|
||||
bool hidden() const;
|
||||
|
||||
/**
|
||||
* Set the parameter's \a hidden status, parametes are not hidden by default.
|
||||
*
|
||||
* \since QGIS 3.28
|
||||
*/
|
||||
void setHidden( bool hidden );
|
||||
|
||||
private:
|
||||
|
||||
QString mName;
|
||||
@ -148,6 +165,7 @@ class SERVER_EXPORT QgsServerQueryStringParameter
|
||||
customValidator mCustomValidator = nullptr;
|
||||
QString mDescription;
|
||||
QVariant mDefaultValue;
|
||||
bool mHidden = false;
|
||||
|
||||
friend class TestQgsServerQueryStringParameter;
|
||||
|
||||
|
@ -813,19 +813,24 @@ QList<QgsServerQueryStringParameter> QgsWfs3CollectionsItemsHandler::parameters(
|
||||
params.push_back( p );
|
||||
}
|
||||
|
||||
// We want to accept both displayName and name.
|
||||
const QgsFields published { publishedFields( mapLayer, context ) };
|
||||
QSet<QString> publishedFieldNames;
|
||||
QStringList publishedFieldNames;
|
||||
QStringList publishedFieldDisplayNames;
|
||||
for ( const auto &f : published )
|
||||
{
|
||||
publishedFieldNames.insert( f.name() );
|
||||
publishedFieldNames.insert( f.displayName() );
|
||||
publishedFieldDisplayNames.push_back( f.displayName() );
|
||||
if ( f.name() != f.displayName() )
|
||||
{
|
||||
publishedFieldNames.push_back( f.name() );
|
||||
}
|
||||
}
|
||||
|
||||
// Properties (CSV list of properties to return)
|
||||
QgsServerQueryStringParameter properties { QStringLiteral( "properties" ), false,
|
||||
QgsServerQueryStringParameter::Type::List,
|
||||
QStringLiteral( "Comma separated list of feature property names to be added to the result. Valid values: %1" )
|
||||
.arg( publishedFieldNames.values().join( QLatin1String( "', '" ) )
|
||||
.arg( publishedFieldDisplayNames.join( QLatin1String( "', '" ) )
|
||||
.append( '\'' )
|
||||
.prepend( '\'' ) ) };
|
||||
|
||||
@ -834,7 +839,7 @@ QList<QgsServerQueryStringParameter> QgsWfs3CollectionsItemsHandler::parameters(
|
||||
const QStringList properties { value.toStringList() };
|
||||
for ( const auto &p : properties )
|
||||
{
|
||||
if ( ! publishedFieldNames.contains( p ) )
|
||||
if ( ! publishedFieldNames.contains( p ) && ! publishedFieldDisplayNames.contains( p ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -992,7 +997,7 @@ json QgsWfs3CollectionsItemsHandler::schema( const QgsServerApiContext &context
|
||||
const QList<QgsServerQueryStringParameter> requestParameters { parameters( layerContext ) };
|
||||
for ( const auto &p : requestParameters )
|
||||
{
|
||||
if ( ! componentNames.contains( p.name() ) )
|
||||
if ( ! p.hidden() && ! componentNames.contains( p.name() ) )
|
||||
componentParameters.push_back( p.data() );
|
||||
}
|
||||
|
||||
@ -1099,10 +1104,13 @@ const QList<QgsServerQueryStringParameter> QgsWfs3CollectionsItemsHandler::field
|
||||
const QgsServerQueryStringParameter fieldParam { fName, false,
|
||||
t, QStringLiteral( "Retrieve features filtered by: %1 (%2)" ).arg( fName, QgsServerQueryStringParameter::typeName( t ) ) };
|
||||
params.push_back( fieldParam );
|
||||
|
||||
// Add real field name if alias was used but set it as hidden
|
||||
if ( fName != f.name() )
|
||||
{
|
||||
const QgsServerQueryStringParameter fieldParam { f.name(), false,
|
||||
QgsServerQueryStringParameter fieldParam { f.name(), false,
|
||||
t, QStringLiteral( "Retrieve features filtered by field: %1 (%2), aliased by %3" ).arg( f.name(), QgsServerQueryStringParameter::typeName( t ), f.alias() ) };
|
||||
fieldParam.setHidden( true );
|
||||
params.push_back( fieldParam );
|
||||
}
|
||||
}
|
||||
|
@ -1098,7 +1098,7 @@ Content-Type: application/vnd.oai.openapi+json;version=3.0
|
||||
"style": "form"
|
||||
},
|
||||
{
|
||||
"description": "Comma separated list of feature property names to be added to the result. Valid values: 'id', 'name', 'utf8nameè'",
|
||||
"description": "Comma separated list of feature property names to be added to the result. Valid values: 'alias_id', 'alias_name', 'utf8nameè'",
|
||||
"explode": false,
|
||||
"in": "query",
|
||||
"name": "properties",
|
||||
|
Loading…
x
Reference in New Issue
Block a user