REST Server
Connexion application setup and configuration module.
Provides a custom JSON encoder for model serialization and the main entry point for the REST API server. Configures and starts the Connexion application with Swagger/OpenAPI specification support.
- class rest_server.JSONEncoder(*args: Any, **kwargs: Any)[source]
Bases:
FlaskJSONEncoderCustom JSON encoder extending Flask’s default encoder with model handling.
Provides specialized serialization for application models while maintaining compatibility with standard Flask serialization for other data types.
- Variables:
include_nulls (bool) – Control null value inclusion in serialized output
Example
To enable null inclusion:
encoder = JSONEncoder() encoder.include_nulls = True
- include_nulls = False
- default(o)[source]
Serialize objects to JSON-compatible formats with model handling.
Handles serialization of Model subclasses by converting them to dictionaries while respecting the include_nulls setting. Falls back to default Flask JSON encoding for other object types.
- Parameters:
o (object) – Object to serialize
- Returns:
Dictionary representation for models, default serialization otherwise
- Return type:
dict | object
- Raises:
TypeError – For non-serializable objects that Flask can’t handle
- rest_server.main()[source]
Configure and start the Connexion REST API server.
Performs the following operations: 1. Creates Connexion application instance 2. Configures custom JSON encoder 3. Loads API specification from swagger.yaml 4. Starts development server on port 8082
Server configuration: - Uses Pythonic parameter handling (snake_case <-> camelCase conversion) - API specification validated at startup - Automatic routing based on OpenAPI spec
- Returns:
None