openapi2callables.server ======================== .. py:module:: openapi2callables.server .. autoapi-nested-parse:: Main module. Attributes ---------- .. autoapisummary:: openapi2callables.server.app openapi2callables.server.pirates_db openapi2callables.server.treasures_db openapi2callables.server.ships_db Classes ------- .. autoapisummary:: openapi2callables.server.PirateRank openapi2callables.server.Ship openapi2callables.server.Treasure openapi2callables.server.Pirate openapi2callables.server.PirateExtended Functions --------- .. autoapisummary:: openapi2callables.server.pirate_endpoint openapi2callables.server.pirate_endpoint_name openapi2callables.server.pirate_endpoint_body openapi2callables.server.update_pirate openapi2callables.server.delete_pirate openapi2callables.server.search_pirates openapi2callables.server.get_pirates openapi2callables.server.add_pirate openapi2callables.server.create_ship openapi2callables.server.get_ships openapi2callables.server.get_ship openapi2callables.server.create_treasure openapi2callables.server.create_extended_pirate openapi2callables.server.search_pirates_advanced openapi2callables.server.update_pirate_partial Module Contents --------------- .. py:data:: app .. py:function:: pirate_endpoint() Pirate endpoint. Simplest possible endpoint; no inputs, only string response .. py:function:: pirate_endpoint_name(name) Pirate endpoint. Simplest possible endpoint; URL input, only string response .. py:class:: PirateRank Bases: :py:obj:`str`, :py:obj:`enum.Enum` str(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'. .. py:attribute:: CAPTAIN :value: 'captain' .. py:attribute:: FIRST_MATE :value: 'first_mate' .. py:attribute:: QUARTERMASTER :value: 'quartermaster' .. py:attribute:: BOATSWAIN :value: 'boatswain' .. py:attribute:: GUNNER :value: 'gunner' .. py:attribute:: SAILOR :value: 'sailor' .. py:class:: Ship(/, **data) Bases: :py:obj:`pydantic.BaseModel` Usage docs: https://docs.pydantic.dev/2.10/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_fields__ A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects. .. attribute:: __pydantic_computed_fields__ A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: name :type: str .. py:attribute:: type :type: str :value: None .. py:attribute:: capacity :type: int :value: None .. py:attribute:: cannons :type: int :value: None .. py:attribute:: year_built :type: Optional[int] :value: None .. py:class:: Treasure(/, **data) Bases: :py:obj:`pydantic.BaseModel` Usage docs: https://docs.pydantic.dev/2.10/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_fields__ A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects. .. attribute:: __pydantic_computed_fields__ A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: name :type: str .. py:attribute:: value :type: float .. py:attribute:: location :type: Optional[str] :value: None .. py:attribute:: is_cursed :type: bool :value: False .. py:class:: Pirate(/, **data) Bases: :py:obj:`pydantic.BaseModel` Usage docs: https://docs.pydantic.dev/2.10/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_fields__ A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects. .. attribute:: __pydantic_computed_fields__ A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: name :type: str .. py:attribute:: age :type: Optional[int] :value: None .. py:attribute:: ship :type: Optional[str] :value: None .. py:attribute:: rank :type: Optional[PirateRank] :value: None .. py:attribute:: joined_date :type: Optional[datetime.date] :value: None .. py:attribute:: skills :type: List[str] :value: None .. py:attribute:: bounty :type: Optional[float] :value: None .. py:attribute:: is_active :type: bool :value: True .. py:class:: PirateExtended(/, **data) Bases: :py:obj:`Pirate` Usage docs: https://docs.pydantic.dev/2.10/concepts/models/ A base class for creating Pydantic models. .. attribute:: __class_vars__ The names of the class variables defined on the model. .. attribute:: __private_attributes__ Metadata about the private attributes of the model. .. attribute:: __signature__ The synthesized `__init__` [`Signature`][inspect.Signature] of the model. .. attribute:: __pydantic_complete__ Whether model building is completed, or if there are still undefined fields. .. attribute:: __pydantic_core_schema__ The core schema of the model. .. attribute:: __pydantic_custom_init__ Whether the model has a custom `__init__` function. .. attribute:: __pydantic_decorators__ Metadata containing the decorators defined on the model. This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. .. attribute:: __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. .. attribute:: __pydantic_parent_namespace__ Parent namespace of the model, used for automatic rebuilding of models. .. attribute:: __pydantic_post_init__ The name of the post-init method for the model, if defined. .. attribute:: __pydantic_root_model__ Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. .. attribute:: __pydantic_serializer__ The `pydantic-core` `SchemaSerializer` used to dump instances of the model. .. attribute:: __pydantic_validator__ The `pydantic-core` `SchemaValidator` used to validate instances of the model. .. attribute:: __pydantic_fields__ A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects. .. attribute:: __pydantic_computed_fields__ A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects. .. attribute:: __pydantic_extra__ A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. .. attribute:: __pydantic_fields_set__ The names of fields explicitly set during instantiation. .. attribute:: __pydantic_private__ Values of private attributes set on the model instance. .. py:attribute:: email :type: Optional[pydantic.EmailStr] :value: None .. py:attribute:: ship_details :type: Optional[Ship] :value: None .. py:attribute:: treasures :type: List[Treasure] :value: None .. py:attribute:: last_seen :type: Optional[datetime.datetime] :value: None .. py:attribute:: metadata :type: Dict[str, Union[str, int, bool]] :value: None .. py:data:: pirates_db :value: [] .. py:data:: treasures_db :value: [] .. py:data:: ships_db :value: [] .. py:function:: pirate_endpoint_body(pirate) Pirate endpoint. Simplest possible endpoint; Post Body input, only string response .. py:function:: update_pirate(name, pirate) Update a pirate's information. .. py:function:: delete_pirate(name) Delete a pirate. .. py:function:: search_pirates(ship) Search pirates by ship. .. py:function:: get_pirates() Get all pirates. .. py:function:: add_pirate(pirate) Add a new pirate. .. py:function:: 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 .. py:function:: 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 .. py:function:: 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 .. py:function:: 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 .. py:function:: 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 .. py:function:: 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 .. py:function:: 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