.. index:: single: http_parameters
.. _http_parameters/0:

.. rst-class:: right

**object**

``http_parameters``
===================

Typed HTTP query, form, path, header, and cookie parameter extraction helpers plus OpenAPI descriptor generation helpers.

| **Availability:** 
|    ``logtalk_load(http_parameters(loader))``

| **Author:** Paulo Moura
| **Version:** 1:0:0
| **Date:** 2026-07-14

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Imports:**
|    ``public`` :ref:`http_json_term_helpers <http_json_term_helpers/0>`
| **Uses:**
|    :ref:`http_core <http_core/0>`
|    :ref:`list <list/0>`
|    :ref:`type <type/0>`

| **Remarks:**
|    (none)

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: parameters/3
.. _http_parameters/0::parameters/3:

``parameters/3``
^^^^^^^^^^^^^^^^

Extracts typed parameters from a normalized HTTP request using the given declaration list. Client-input failures throw ``error(http_parameter_validation(Errors), Context)`` where ``Errors`` is a non-empty list of structured parameter errors.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``parameters(Request,Declarations,Parameters)``
| **Mode and number of proofs:**
|    ``parameters(+compound,+list(compound),-list(compound))`` - ``one_or_error``

| **Exceptions:**
|    ``Request`` is not a valid normalized HTTP request term:
|        ``domain_error(http_request,Request)``
|    ``Declarations`` is a variable or a partial list:
|        ``instantiation_error``
|    ``Declarations`` is neither a variable nor a list:
|        ``type_error(list,Declarations)``
|    An element ``Declaration`` of the list ``Declarations`` is not a valid HTTP parameter declaration:
|        ``domain_error(http_parameter_declaration,Declaration)``
|    An element ``Declaration`` of the list ``Declarations`` has an invalid parameter name:
|        ``domain_error(http_parameter_name,Name)``
|    An element ``Declaration`` of the list ``Declarations`` has an invalid parameter source:
|        ``domain_error(http_parameter_source,Source)``
|    An element ``Declaration`` of the list ``Declarations`` has an invalid parameter type:
|        ``domain_error(http_parameter_type,Type)``
|    An element ``Declaration`` of the list ``Declarations`` has duplicated declaration options:
|        ``domain_error(http_parameter_options,duplicate(Option))``
|    An element ``Declaration`` of the list ``Declarations`` has an invalid declaration option:
|        ``domain_error(http_parameter_option,Option)``
|    An element ``Declaration`` of the list ``Declarations`` has an invalid description:
|        ``domain_error(http_parameter_description,Description)``
|    An element ``Declaration`` of the list ``Declarations`` has an invalid default value:
|        ``domain_error(http_parameter_default(Type),invalid_default(Name,Value))``
|    ``Declarations`` contains duplicated declarations for a parameter source:
|        ``domain_error(http_parameter_declaration(Name,Source),duplicate)``
|    The request parameters fail declared type or constraint validation:
|        ``error(http_parameter_validation(Errors),Context)``


------------

.. index:: parameter/3
.. _http_parameters/0::parameter/3:

``parameter/3``
^^^^^^^^^^^^^^^

Extracts a single typed parameter from a normalized HTTP request using the given declaration. Optional absent parameters fail instead of throwing an error.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``parameter(Request,Declaration,Value)``
| **Mode and number of proofs:**
|    ``parameter(+compound,+compound,-term)`` - ``zero_or_one``


------------

.. index:: open_api_parameters/2
.. _http_parameters/0::open_api_parameters/2:

``open_api_parameters/2``
^^^^^^^^^^^^^^^^^^^^^^^^^

Generates OpenAPI ``parameter/5`` descriptors for query, path, header, and cookie declarations.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``open_api_parameters(Declarations,Parameters)``
| **Mode and number of proofs:**
|    ``open_api_parameters(+list(compound),-list(compound))`` - ``one_or_error``

| **Exceptions:**
|    ``Declarations`` is a variable or a partial list:
|        ``instantiation_error``
|    ``Declarations`` is neither a variable nor a list:
|        ``type_error(list,Declarations)``
|    An element ``Declaration`` of the list ``Declarations`` is not a valid HTTP parameter declaration:
|        ``domain_error(http_parameter_declaration,Declaration)``
|    An element ``Declaration`` of the list ``Declarations`` has an invalid parameter name:
|        ``domain_error(http_parameter_name,Name)``
|    An element ``Declaration`` of the list ``Declarations`` has an invalid parameter source:
|        ``domain_error(http_parameter_source,Source)``
|    An element ``Declaration`` of the list ``Declarations`` has an invalid parameter type:
|        ``domain_error(http_parameter_type,Type)``
|    An element ``Declaration`` of the list ``Declarations`` has an invalid declaration option:
|        ``domain_error(http_parameter_option,Option)``
|    An element ``Declaration`` of the list ``Declarations`` has duplicated declaration options:
|        ``domain_error(http_parameter_options,duplicate(Option))``
|    ``Declarations`` contains duplicated declarations for a parameter source:
|        ``domain_error(http_parameter_declaration(Name,Source),duplicate)``


------------

.. index:: open_api_request_body/3
.. _http_parameters/0::open_api_request_body/3:

``open_api_request_body/3``
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Generates an OpenAPI ``request_body/3`` descriptor for form declarations using the given description. Fails when the declaration list contains no form parameters.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``open_api_request_body(Declarations,Description,RequestBody)``
| **Mode and number of proofs:**
|    ``open_api_request_body(+list(compound),+atom,-compound)`` - ``zero_or_one``


------------

.. index:: open_api_bad_request_response/1
.. _http_parameters/0::open_api_bad_request_response/1:

``open_api_bad_request_response/1``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Returns the default OpenAPI ``400 Bad Request`` response descriptor used by router integrations.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``open_api_bad_request_response(Response)``
| **Mode and number of proofs:**
|    ``open_api_bad_request_response(-compound)`` - ``one``


------------

Protected predicates
--------------------

(no local declarations; see entity ancestors if any)

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

