Ejemplo n.º 1
0
class SpecCorrelationIdObject:

    description: Optional[str]
    """Optional description of the identifier. CommonMark syntax can be used for rich text representation."""

    location: str
    """ Required. runtime expression that specifies the location of the correlation ID.
        $message.header#/MQMD/CorrelId
    """

    _validation_enabled: bool

    def __init__(self,
                 location: str,
                 description: str,
                 validation_enabled: bool = True):
        self._validation_enabled = validation_enabled
        self.description = description or SpecEmptyObject()
        self.location = location

    @property
    def description(self) -> str:
        return self._description.value

    @property
    def url(self) -> str:
        return self._url.value

    @property
    def validation_enabled(self) -> bool:
        return self._validation_enabled

    @description.setter
    def description(self, value: str):
        self._description = SpecStringObject("description", value,
                                             self._validation_enabled)
        self._description.validate()

    @url.setter
    def url(self, value: str) -> str:
        self._url = SpecStringObject("url", value, self._validation_enabled)
        self._url.validate()

    def compose(self):
        return {
            "externalDocs": {
                self._url.compose(),
                self._description.compose(),
            },
        }
Ejemplo n.º 2
0
class SpecExternalDocumentationObject:

    _url: SpecStringObject
    """ Required. The URL for the target documentation. Value MUST be in the format of a URL."""

    _description: Optional[SpecStringObject]
    """ A short description of the target documentation. CommonMark syntax can be used for rich text representation. """

    _validation_enabled: bool

    def __init__(self,
                 url: str,
                 description: str = None,
                 validation_enabled: bool = True):
        self._validation_enabled = validation_enabled
        self.description = description or SpecEmptyObject()
        self.url = url

    @property
    def description(self) -> str:
        return self._description.value

    @property
    def url(self) -> str:
        return self._url.value

    @property
    def validation_enabled(self) -> bool:
        return self._validation_enabled

    @description.setter
    def description(self, value: str):
        self._description = SpecStringObject("description", value,
                                             self._validation_enabled)
        self._description.validate()

    @url.setter
    def url(self, value: str):
        self._url = SpecStringObject("url", value, self._validation_enabled)
        self._url.validate()

    def compose(self):
        return {
            "externalDocs": {
                **self._url.compose(),
                **self._description.compose(),
            },
        }
Ejemplo n.º 3
0
class SpecLicenseObject:

    _name: SpecStringObject
    """The identifying name of the contact person/organization"""

    _url: SpecStringObject
    """The URL pointing to the contact information. MUST be in the format of a URL"""

    _validation_enabled: bool

    def __init__(self, name: str, url: str, validation_enabled: bool = True):
        self._validation_enabled = validation_enabled
        self.name = name
        self.url = url

    @property
    def name(self) -> str:
        return self._name.value

    @property
    def url(self) -> str:
        return self._url.value

    @property
    def validation_enabled(self) -> bool:
        return self._validation_enabled

    @name.setter
    def name(self, value: str):
        self._name = SpecStringObject("name", value, self._validation_enabled)
        self._name.validate()

    @url.setter
    def url(self, value: str) -> str:
        self._url = SpecStringObject("url", value, self._validation_enabled)
        self._url.validate()

    def compose(self):
        return {
            "license": {
                self._name.compose(),
                self._url.compose(),
            },
        }
Ejemplo n.º 4
0
 def name(self, value: str):
     self._name = SpecStringObject("name", value, self._validation_enabled)
     self._name.validate()
Ejemplo n.º 5
0
 def email(self, value: str) -> str:
     self._email = SpecStringObject("email", value,
                                    self._validation_enabled)
     self._email.validate()
Ejemplo n.º 6
0
 def url(self, value: str) -> str:
     self._url = SpecStringObject("url", value, self._validation_enabled)
     self._url.validate()
Ejemplo n.º 7
0
 def app_id(self, value: str):
     self._app_id = SpecStringObject("id", value, self._validation_enabled)
     self._app_id.validate()
Ejemplo n.º 8
0
 def asyncapi_ver(self, value: str):
     self._asyncapi_ver = SpecStringObject("asyncapi", value,
                                           self._validation_enabled)
     self._asyncapi_ver.validate()
Ejemplo n.º 9
0
class SpecParameterObject:
    """Describes a parameter included in a channel name"""

    _schema: Optional[SpecStringObject]
    """Definition of the parameter"""

    _description: Optional[SpecStringObject]
    """A verbose explanation of the parameter. CommonMark syntax can be used for rich text representation"""

    _location: Optional[SpecStringObject]
    """ A runtime expression that specifies the location of the parameter value.
        Even when a definition for the target field exists, it MUST NOT be used to validate this parameter but,
        instead, the schema property MUST be used
    """

    _validation_enabled: bool

    def __init__(
        self,
        schema: Optional[str] = None,
        description: str = None,
        location: Optional[str] = None,
        validation_enabled: bool = True,
    ):
        self._validation_enabled = validation_enabled
        self.schema = schema or SpecEmptyObject()
        self.description = description or SpecEmptyObject()
        self.location = location or SpecEmptyObject()

    @property
    def schema(self) -> str:
        return self._schema.value

    @property
    def description(self) -> str:
        return self._description.value

    @property
    def location(self) -> str:
        return self._location.value

    @property
    def validation_enabled(self) -> bool:
        return self._validation_enabled

    @schema.setter
    def schema(self, value: str):
        self._schema = SpecStringObject("schema", value,
                                        self._validation_enabled)
        self._schema.validate()

    @description.setter
    def description(self, value: str):
        self._description = SpecStringObject("description", value,
                                             self._validation_enabled)
        self._description.validate()

    @location.setter
    def location(self, value: str):
        self._location = SpecStringObject("location", value,
                                          self._validation_enabled)
        self._location.validate()

    def compose(self):
        return {
            **self._schema.compose(),
            **self._description.compose(),
            **self._location.compose(),
        }
Ejemplo n.º 10
0
 def terms_of_service(self, value: str):
     self._terms_of_service = SpecStringObject("terms_of_service", value,
                                               self._validation_enabled)
     self._terms_of_service.validate()
Ejemplo n.º 11
0
 def version(self, value: str):
     self._version = SpecStringObject("version", value,
                                      self._validation_enabled)
     self._version.validate()
Ejemplo n.º 12
0
 def title(self, value: str):
     self._title = SpecStringObject("title", value,
                                    self._validation_enabled)
     self._title.validate()
Ejemplo n.º 13
0
class SpecInfoObject:

    title: str
    """The title of the application. """

    version: str
    """Provides the version of the application API (not to be confused with the specification version). """

    description: Optional[str]
    """ A short description of the application. CommonMark syntax can be used for rich text representation. """

    terms_of_service: Optional[str]
    """ A URL to the Terms of Service for the API. MUST be in the format of a URL. """

    contact: Optional[SpecContactObject]
    """ Contact Object	The contact information for the exposed API. """

    license: Optional[SpecLicenseObject]
    """ License Object	The license information for the exposed API. """

    _validation_enabled: bool

    def __init__(
        self,
        title: str,
        version: str,
        description: Optional[str] = None,
        terms_of_service: Optional[str] = None,
        contact: Optional[SpecContactObject] = None,
        license: Optional[SpecLicenseObject] = None,
        validation_enabled: bool = True,
    ) -> None:
        self.validation_enabled = validation_enabled
        self.terms_of_service = terms_of_service
        self.description = description
        self.version = version
        self.contact = contact
        self.license = license
        self.title = title

    @property
    def validation_enabled(self) -> bool:
        return self._validation_enabled

    @property
    def title(self) -> str:
        return self._title.value

    @property
    def version(self) -> str:
        return self._version.value

    @property
    def description(self) -> str:
        return self._description.value

    @property
    def terms_of_service(self) -> str:
        return self._terms_of_service.value

    @property
    def contact(self) -> str:
        return self._contact

    @property
    def license(self) -> str:
        return self._license

    @title.setter
    def title(self, value: str):
        self._title = SpecStringObject("title", value,
                                       self._validation_enabled)
        self._title.validate()

    @version.setter
    def version(self, value: str):
        self._version = SpecStringObject("version", value,
                                         self._validation_enabled)
        self._version.validate()

    @description.setter
    def description(self, value: str):
        self._description = SpecStringObject("description", value,
                                             self._validation_enabled)
        self._description.validate()

    @terms_of_service.setter
    def terms_of_service(self, value: str):
        self._terms_of_service = SpecStringObject("terms_of_service", value,
                                                  self._validation_enabled)
        self._terms_of_service.validate()

    @contact.setter
    def contact(self, value: SpecContactObject):
        assert isinstance(value, SpecContactObject)
        self._contact = value

    @license.setter
    def license(self, value: SpecLicenseObject):
        assert isinstance(value, SpecLicenseObject)
        self._license = value

    def compose(self):
        return {
            "info": {
                self._title.compose(),
                self._version.compose(),
                self._description.compose(),
                self._terms_of_service.compose(),
                self._contact.compose(),
                self._license.compose(),
            },
        }
Ejemplo n.º 14
0
 def schema(self, value: str):
     self._schema = SpecStringObject("schema", value,
                                     self._validation_enabled)
     self._schema.validate()
Ejemplo n.º 15
0
class SpecTagObject:

    _name: SpecStringObject
    """Required. The name of the tag."""

    _description: Optional[SpecStringObject]
    """A short description for the tag. CommonMark syntax can be used for rich text representation."""

    _external_docs: Optional[SpecExternalDocumentationObject]
    """Documentation Object	Additional external documentation for this tag."""

    _validation_enabled: bool

    def __init__(
        self,
        name: str,
        description: Optional[str] = None,
        external_docs: Optional[SpecExternalDocumentationObject] = None,
        validation_enabled: bool = True,
    ):
        self._validation_enabled = validation_enabled
        self.external_docs = external_docs or SpecEmptyObject()
        self.description = description or SpecEmptyObject()
        self.name = name

    @property
    def validation_enabled(self) -> bool:
        return self._validation_enabled

    @property
    def name(self) -> str:
        return self._name.value

    @property
    def description(self) -> str:
        return self._description.value

    @property
    def external_docs(self) -> SpecExternalDocumentationObject:
        return self._external_docs

    @name.setter
    def name(self, value: str):
        self._name = SpecStringObject("name", value, self._validation_enabled)
        self._name.validate()

    @description.setter
    def description(self, value: str) -> str:
        self._description = SpecStringObject("description", value,
                                             self._validation_enabled)
        self._description.validate()

    @external_docs.setter
    def external_docs(self, value: SpecExternalDocumentationObject) -> str:
        assert isinstance(value, SpecExternalDocumentationObject)
        self._external_docs = value

    def spec(self):
        return {
            "externalDocs": {
                **self._name.spec(),
                **self._description.spec(),
                **self._external_docs.spec(),
            },
        }
Ejemplo n.º 16
0
 def description(self, value: str) -> str:
     self._description = SpecStringObject("description", value,
                                          self._validation_enabled)
     self._description.validate()
Ejemplo n.º 17
0
class SpecAsyncApiObject:

    _asyncapi: SpecStringObject
    """ Required. AsyncAPI Version String.
        Specifies the AsyncAPI Specification version being used.
        It can be used by tooling Specifications and clients to interpret the version.
        The structure shall be major.minor.patch, where patch versions
        must be compatible with the existing major.minor tooling.
        Typically patch versions will be introduced to address errors in the documentation,
        and tooling should typically be compatible with the corresponding major.minor (1.0.*).
        Patch versions will correspond to patches of this document.
    """

    _id: Optional[SpecStringObject]
    """ Identifier Identifier of the application the AsyncAPI document is defining. """

    _info: SpecInfoObject
    """	Required. Provides metadata about the API. The metadata can be used by the clients if needed. """

    # servers: Optional[Dict[str,Server]]
    # """	Servers Object	Provides connection details of servers. """

    # channels: Dict[str, Channel]
    # """ Required. Channels Object	Required The available channels and messages for the API. """

    # components: Optional[Components]  # $checked, here
    # """	Components Object	An element to hold various schemas for the specification. """

    _tags: Optional[SpecTagListObject]
    """A list of tags used by the specification with additional metadata. Each tag name in the list MUST be unique. """

    _external_docs: Optional[SpecExternalDocumentationObject]
    """Additional external documentation. """

    _validation_enabled: bool

    def __init__(
        self,
        asyncapi_ver: str,
        info: SpecInfoObject,
        channels: dict,
        components: Optional[dict] = None,
        servers: Optional[dict] = None,
        app_id: Optional[str] = None,
        tags: Optional[SpecTagListObject] = None,
        external_docs: Optional[SpecExternalDocumentationObject] = None,
        validation_enabled: bool = True,
    ):
        self._validation_enabled = validation_enabled
        self.external_docs = external_docs or SpecEmptyObject()
        self.components = components or SpecEmptyObject()
        self.servers = servers or SpecEmptyObject()
        self.app_id = app_id or SpecEmptyObject()
        self.tags = tags or SpecEmptyObject()
        self.asyncapi_ver = asyncapi_ver
        self.channels = channels
        self.info = info

    @property
    def asyncapi_ver(self) -> str:
        return self._asyncapi_ver.value

    @property
    def app_id(self) -> str:
        return self._app_id.value

    @property
    def info(self) -> SpecInfoObject:
        return self._info

    @property
    def channels(self) -> str:
        return self._channels

    @property
    def components(self) -> str:
        return self._components

    @property
    def servers(self) -> str:
        return self._servers

    @property
    def tags(self) -> SpecTagListObject:
        return self._tags

    @property
    def external_docs(self) -> SpecExternalDocumentationObject:
        return self._external_docs

    @property
    def validation_enabled(self) -> bool:
        return self._validation_enabled

    @asyncapi_ver.setter
    def asyncapi_ver(self, value: str):
        self._asyncapi_ver = SpecStringObject("asyncapi", value,
                                              self._validation_enabled)
        self._asyncapi_ver.validate()

    @app_id.setter
    def app_id(self, value: str):
        self._app_id = SpecStringObject("id", value, self._validation_enabled)
        self._app_id.validate()

    @info.setter
    def info(self, value: str):
        assert isinstance(value, str)
        self._info = value

    @channels.setter
    def channels(self, value: str):
        assert isinstance(value, str)
        self._channels = value

    @components.setter
    def components(self, value: str):
        assert isinstance(value, str)
        self._components = value

    @servers.setter
    def servers(self, value: str):
        assert isinstance(value, str)
        self._servers = value

    @tags.setter
    def tags(self, value: str):
        assert isinstance(value, str)
        self._tags = value

    @external_docs.setter
    def external_docs(self, value: str):
        assert isinstance(value, str)
        self._external_docs = value

    def compose(self):
        return {
            **self._asyncapi_ver.compose(),
            **self._external_docs.compose(),
            **self._components.compose(),
            **self._channels.compose(),
            **self._servers.compose(),
            **self._app_id.compose(),
            **self._tags.compose(),
            **self._info.compose(),
        }