Class: QgsServerQueryStringParameter

Holds the information regarding a query string input parameter and its validation.

The class is extendable through custom validators (C++ only) and/or by subclassing and overriding the value() method.

Added in version 3.10.

Enums

Type

The Type enum represents the parameter type

Methods

description

Returns parameter description

hidden

Returns True if the parameter is hidden from the schema.

name

Returns the name of the parameter

setDescription

Sets validator description

setHidden

Set the parameter's hidden status, parameters are not hidden by default.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsServerQueryStringParameter. See the FAQ for more details.

value

Extracts the value from the request context by validating the parameter value and converting it to its proper Type.

Static Methods

typeName

Returns the name of the type

class qgis.server.QgsServerQueryStringParameter[source]

Bases: object

__init__(name: str | None, required: bool = False, type: QgsServerQueryStringParameter.Type = QgsServerQueryStringParameter.Type.String, description: str | None = '', defaultValue: Any = None)

Constructs a QgsServerQueryStringParameter object.

Parameters:
  • name (Optional[str]) – parameter name

  • required (bool = False)

  • type (QgsServerQueryStringParameter.Type = QgsServerQueryStringParameter.Type.String) – the parameter type

  • description (Optional[str] = '') – parameter description

  • defaultValue (Any = None) – default value, it is ignored if the parameter is required

__init__(a0: QgsServerQueryStringParameter)
Parameters:

a0 (QgsServerQueryStringParameter)

class Type(*values)

Bases: IntEnum

The Type enum represents the parameter type

  • String: Parameter is a string

  • Integer: Parameter is an integer

  • Double: Parameter is a double

  • Boolean: Parameter is a boolean

  • List: Parameter is a (comma separated) list of strings, the handler will perform any further required conversion of the list values

Boolean = 1
Double = 6
Integer = 4
List = 11
String = 10
description(self) str[source]

Returns parameter description

Return type:

str

hidden(self) bool[source]

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.

Added in version 3.28.

Return type:

bool

name(self) str[source]

Returns the name of the parameter

Return type:

str

setDescription(self, description: str | None)[source]

Sets validator description

Parameters:

description (Optional[str])

setHidden(self, hidden: bool)[source]

Set the parameter’s hidden status, parameters are not hidden by default.

Added in version 3.28.

Parameters:

hidden (bool)

static typeName(type: QgsServerQueryStringParameter.Type) str[source]

Returns the name of the type

Parameters:

type (QgsServerQueryStringParameter.Type)

Return type:

str

virtual value(self, context: QgsServerApiContext) Any[source]

Extracts the value from the request context by validating the parameter value and converting it to its proper Type. If the value is not set and a default was not provided an invalid QVariant is returned.

Validation steps:

  • required

  • can convert to proper Type

  • custom validator (if set - not available in Python bindings)

See also

setCustomValidator() (not available in Python bindings)

Return type:

Any

Returns:

the parameter value or an invalid QVariant if not found (and not required)

Raises:

QgsServerApiBadRequestError – if validation fails

Parameters:

context (QgsServerApiContext)