openapi2callables.server
Main module.
Attributes
Classes
str(object='') -> str |
|
Usage docs: https://docs.pydantic.dev/2.10/concepts/models/ |
|
Usage docs: https://docs.pydantic.dev/2.10/concepts/models/ |
|
Usage docs: https://docs.pydantic.dev/2.10/concepts/models/ |
|
Usage docs: https://docs.pydantic.dev/2.10/concepts/models/ |
Functions
Pirate endpoint. Simplest possible endpoint; no inputs, only string response |
|
|
Pirate endpoint. Simplest possible endpoint; URL input, only string response |
|
Pirate endpoint. Simplest possible endpoint; Post Body input, only string response |
|
Update a pirate's information. |
|
Delete a pirate. |
|
Search pirates by ship. |
Get all pirates. |
|
|
Add a new pirate. |
|
Create a new ship with detailed information. |
|
Get a list of ships with pagination and sorting. |
|
Get a ship by ID. |
|
Add a new treasure to the database. |
|
Create a new pirate with extended information. |
|
Advanced search for pirates with multiple optional filters. |
|
Partially update a pirate's information. |
Module Contents
- openapi2callables.server.app
- openapi2callables.server.pirate_endpoint()
Pirate endpoint. Simplest possible endpoint; no inputs, only string response
- Return type:
str
- openapi2callables.server.pirate_endpoint_name(name)
Pirate endpoint. Simplest possible endpoint; URL input, only string response
- Parameters:
name (str)
- Return type:
str
- class openapi2callables.server.PirateRank
Bases:
str,enum.Enumstr(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.
- CAPTAIN = 'captain'
- FIRST_MATE = 'first_mate'
- QUARTERMASTER = 'quartermaster'
- BOATSWAIN = 'boatswain'
- GUNNER = 'gunner'
- SAILOR = 'sailor'
- class openapi2callables.server.Ship(/, **data)
Bases:
pydantic.BaseModelUsage docs: https://docs.pydantic.dev/2.10/concepts/models/
A base class for creating Pydantic models.
- Parameters:
data (Any)
- __class_vars__
The names of the class variables defined on the model.
- __private_attributes__
Metadata about the private attributes of the model.
- __signature__
The synthesized __init__ [Signature][inspect.Signature] of the model.
- __pydantic_complete__
Whether model building is completed, or if there are still undefined fields.
- __pydantic_core_schema__
The core schema of the model.
- __pydantic_custom_init__
Whether the model has a custom __init__ function.
- __pydantic_decorators__
Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
- __pydantic_generic_metadata__
Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
- __pydantic_parent_namespace__
Parent namespace of the model, used for automatic rebuilding of models.
- __pydantic_post_init__
The name of the post-init method for the model, if defined.
- __pydantic_root_model__
Whether the model is a [RootModel][pydantic.root_model.RootModel].
- __pydantic_serializer__
The pydantic-core SchemaSerializer used to dump instances of the model.
- __pydantic_validator__
The pydantic-core SchemaValidator used to validate instances of the model.
- __pydantic_fields__
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
- __pydantic_computed_fields__
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
- __pydantic_extra__
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.
- __pydantic_fields_set__
The names of fields explicitly set during instantiation.
- __pydantic_private__
Values of private attributes set on the model instance.
- name: str
- type: str = None
- capacity: int = None
- cannons: int = None
- year_built: int | None = None
- class openapi2callables.server.Treasure(/, **data)
Bases:
pydantic.BaseModelUsage docs: https://docs.pydantic.dev/2.10/concepts/models/
A base class for creating Pydantic models.
- Parameters:
data (Any)
- __class_vars__
The names of the class variables defined on the model.
- __private_attributes__
Metadata about the private attributes of the model.
- __signature__
The synthesized __init__ [Signature][inspect.Signature] of the model.
- __pydantic_complete__
Whether model building is completed, or if there are still undefined fields.
- __pydantic_core_schema__
The core schema of the model.
- __pydantic_custom_init__
Whether the model has a custom __init__ function.
- __pydantic_decorators__
Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
- __pydantic_generic_metadata__
Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
- __pydantic_parent_namespace__
Parent namespace of the model, used for automatic rebuilding of models.
- __pydantic_post_init__
The name of the post-init method for the model, if defined.
- __pydantic_root_model__
Whether the model is a [RootModel][pydantic.root_model.RootModel].
- __pydantic_serializer__
The pydantic-core SchemaSerializer used to dump instances of the model.
- __pydantic_validator__
The pydantic-core SchemaValidator used to validate instances of the model.
- __pydantic_fields__
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
- __pydantic_computed_fields__
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
- __pydantic_extra__
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.
- __pydantic_fields_set__
The names of fields explicitly set during instantiation.
- __pydantic_private__
Values of private attributes set on the model instance.
- name: str
- value: float
- location: str | None = None
- is_cursed: bool = False
- class openapi2callables.server.Pirate(/, **data)
Bases:
pydantic.BaseModelUsage docs: https://docs.pydantic.dev/2.10/concepts/models/
A base class for creating Pydantic models.
- Parameters:
data (Any)
- __class_vars__
The names of the class variables defined on the model.
- __private_attributes__
Metadata about the private attributes of the model.
- __signature__
The synthesized __init__ [Signature][inspect.Signature] of the model.
- __pydantic_complete__
Whether model building is completed, or if there are still undefined fields.
- __pydantic_core_schema__
The core schema of the model.
- __pydantic_custom_init__
Whether the model has a custom __init__ function.
- __pydantic_decorators__
Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
- __pydantic_generic_metadata__
Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
- __pydantic_parent_namespace__
Parent namespace of the model, used for automatic rebuilding of models.
- __pydantic_post_init__
The name of the post-init method for the model, if defined.
- __pydantic_root_model__
Whether the model is a [RootModel][pydantic.root_model.RootModel].
- __pydantic_serializer__
The pydantic-core SchemaSerializer used to dump instances of the model.
- __pydantic_validator__
The pydantic-core SchemaValidator used to validate instances of the model.
- __pydantic_fields__
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
- __pydantic_computed_fields__
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
- __pydantic_extra__
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.
- __pydantic_fields_set__
The names of fields explicitly set during instantiation.
- __pydantic_private__
Values of private attributes set on the model instance.
- name: str
- age: int | None = None
- ship: str | None = None
- rank: PirateRank | None = None
- joined_date: datetime.date | None = None
- skills: List[str] = None
- bounty: float | None = None
- is_active: bool = True
- class openapi2callables.server.PirateExtended(/, **data)
Bases:
PirateUsage docs: https://docs.pydantic.dev/2.10/concepts/models/
A base class for creating Pydantic models.
- Parameters:
data (Any)
- __class_vars__
The names of the class variables defined on the model.
- __private_attributes__
Metadata about the private attributes of the model.
- __signature__
The synthesized __init__ [Signature][inspect.Signature] of the model.
- __pydantic_complete__
Whether model building is completed, or if there are still undefined fields.
- __pydantic_core_schema__
The core schema of the model.
- __pydantic_custom_init__
Whether the model has a custom __init__ function.
- __pydantic_decorators__
Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
- __pydantic_generic_metadata__
Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
- __pydantic_parent_namespace__
Parent namespace of the model, used for automatic rebuilding of models.
- __pydantic_post_init__
The name of the post-init method for the model, if defined.
- __pydantic_root_model__
Whether the model is a [RootModel][pydantic.root_model.RootModel].
- __pydantic_serializer__
The pydantic-core SchemaSerializer used to dump instances of the model.
- __pydantic_validator__
The pydantic-core SchemaValidator used to validate instances of the model.
- __pydantic_fields__
A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
- __pydantic_computed_fields__
A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
- __pydantic_extra__
A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.
- __pydantic_fields_set__
The names of fields explicitly set during instantiation.
- __pydantic_private__
Values of private attributes set on the model instance.
- email: pydantic.EmailStr | None = None
- last_seen: datetime.datetime | None = None
- metadata: Dict[str, str | int | bool] = None
- openapi2callables.server.pirates_db = []
- openapi2callables.server.treasures_db = []
- openapi2callables.server.ships_db = []
- openapi2callables.server.pirate_endpoint_body(pirate)
Pirate endpoint. Simplest possible endpoint; Post Body input, only string response
- Parameters:
pirate (Pirate)
- Return type:
str
- openapi2callables.server.update_pirate(name, pirate)
Update a pirate’s information.
- Parameters:
name (str)
pirate (Pirate)
- Return type:
str
- openapi2callables.server.delete_pirate(name)
Delete a pirate.
- Parameters:
name (str)
- Return type:
str
- openapi2callables.server.search_pirates(ship)
Search pirates by ship.
- Parameters:
ship (str)
- Return type:
List[Pirate]
- openapi2callables.server.add_pirate(pirate)
Add a new pirate.
- Parameters:
pirate (Pirate)
- Return type:
str
- openapi2callables.server.create_ship(ship, x_api_key=Header(None, description='API key for authentication'))
Create a new ship with detailed information.
This endpoint demonstrates: - Custom status code - Header parameters - Complex response model
- openapi2callables.server.get_ships(skip=Query(0, description='Number of ships to skip', ge=0), limit=Query(10, description='Maximum number of ships to return', ge=1, le=100), sort_by=Query('name', description='Field to sort by'), order=Query('asc', description='Sort order (asc or desc)'))
Get a list of ships with pagination and sorting.
This endpoint demonstrates: - Query parameters with validation - Pagination - Sorting options
- Parameters:
skip (int)
limit (int)
sort_by (str)
order (str)
- Return type:
List[Ship]
- openapi2callables.server.get_ship(ship_id=Path(..., description='The ID of the ship to get', ge=0), include_crew=Query(False, description='Whether to include crew information'))
Get a ship by ID.
This endpoint demonstrates: - Path parameters with validation - Optional query parameters affecting response
- Parameters:
ship_id (int)
include_crew (bool)
- Return type:
- openapi2callables.server.create_treasure(treasure, pirate_id=Query(None, description='ID of the pirate who found the treasure'))
Add a new treasure to the database.
This endpoint demonstrates: - Optional query parameters - Complex request body
- openapi2callables.server.create_extended_pirate(pirate=Body(..., description='Extended pirate information with nested objects'), session_id=Cookie(None, description='Session ID for tracking'))
Create a new pirate with extended information.
This endpoint demonstrates: - Complex nested objects - Cookie parameters - Detailed request body with annotations
- Parameters:
pirate (PirateExtended)
session_id (str)
- Return type:
- openapi2callables.server.search_pirates_advanced(name=Query(None, description='Filter by name (case-insensitive, partial match)'), min_age=Query(None, description='Minimum age', ge=0), max_age=Query(None, description='Maximum age', ge=0), rank=Query(None, description='Filter by rank'), skills=Query(None, description='Filter by skills (must have all listed skills)'), active_only=Query(True, description='Only include active pirates'))
Advanced search for pirates with multiple optional filters.
This endpoint demonstrates: - Multiple optional query parameters - Enum parameters - Array parameters - Boolean flags
- Parameters:
name (Optional[str])
min_age (Optional[int])
max_age (Optional[int])
rank (Optional[PirateRank])
skills (Optional[List[str]])
active_only (bool)
- Return type:
List[Pirate]
- openapi2callables.server.update_pirate_partial(pirate_id=Path(..., description='The ID of the pirate to update', ge=0), name=Body(None, description='New name for the pirate'), age=Body(None, description='New age for the pirate'), ship=Body(None, description='New ship for the pirate'), rank=Body(None, description='New rank for the pirate'), skills=Body(None, description='New skills for the pirate'), is_active=Body(None, description='Whether the pirate is active'))
Partially update a pirate’s information.
This endpoint demonstrates: - PATCH method for partial updates - Multiple optional body parameters
- Parameters:
pirate_id (int)
name (Optional[str])
age (Optional[int])
ship (Optional[str])
rank (Optional[PirateRank])
skills (Optional[List[str]])
is_active (Optional[bool])
- Return type: