python-paho-template icon indicating copy to clipboard operation
python-paho-template copied to clipboard

Handler the list, nested object and required properties

Open tornabene opened this issue 2 years ago • 3 comments

Reason/Context

Handler the list, nested object and required properties

Description

Please try answering few of those questions

  • This implements sequence class with correct class
  • This implements the not required properties
  • This implement a nested class

tornabene avatar Nov 30 '23 13:11 tornabene

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

github-actions[bot] avatar Nov 30 '23 13:11 github-actions[bot]

This is the exampe

S3Data: type: object additionalProperties: readOnly: true writeOnly: false uniqueItems: false required: - s3Bucket - s3Key properties: s3Bucket: type: string s3Key: type: string FileS3Temp: type: object additionalProperties: readOnly: true writeOnly: false uniqueItems: false required: - s3Bucket - s3Key - filename - sha512 properties: s3Bucket: type: string s3Key: type: string filename: type: string sha512: type: string FileS3Attribute: type: object additionalProperties: readOnly: true writeOnly: false uniqueItems: false required: - event_type - resource_id - company_id - client_id - user_id - username - filename properties: event_type: type: string $ref: '#/components/schemas/EventType' resource_id: type: string company_id: type: string client_id: type: string user_id: type: string username: type: string filename: type: string event_id: type: string optional: true parent_id: type: string optional: true FileS3Event: type: object additionalProperties: readOnly: true writeOnly: false uniqueItems: false required: - attribute - s3Data - eventType - contentType properties: s3Data: type: object $ref: '#/components/schemas/S3Data' attribute: type: string $ref: '#/components/schemas/FileS3Attribute' eventType: type: string $ref: '#/components/schemas/EventType' contentType: type: string classifiedType: type: string optional: true $ref: '#/components/schemas/ClassifiedType' eventId: type: string optional: true errorMessage: type: string optional: true resourceStatus: type: string optional: true $ref: '#/components/schemas/ResourceStatus' pdfImagesExtracted: type: array optional: true items: type: object $ref: '#/components/schemas/FileS3Temp' parentResources: type: array optional: true items: type: string

from enum import Enum from typing import Sequence from entity import Entity

from fileS3Temp import FileS3Temp

class FileS3Event(Entity):

class S3Data(Entity):

    def __init__(
            self,
            s3Bucket: str,
            s3Key: str):
        self.s3Bucket = s3Bucket
        self.s3Key = s3Key


class Attribute(Entity):

    class EventType(str, Enum):
        CAR = 'CAR'
        CONTENT = 'CONTENT'
        UNRECOGNIZED = 'UNRECOGNIZED'

    def __init__(
            self,
            eventType: EventType,
            resourceId: str,
            companyId: str,
            clientId: str,
            userId: str,
            username: str,
            filename: str,
            eventId: str,
            parentId: str):
        self.eventType = eventType
        self.resourceId = resourceId
        self.companyId = companyId
        self.clientId = clientId
        self.userId = userId
        self.username = username
        self.filename = filename
        self.eventId = eventId
        self.parentId = parentId


class EventType(str, Enum):
    CAR = 'CAR'
    CONTENT = 'CONTENT'
    UNRECOGNIZED = 'UNRECOGNIZED'

class ClassifiedType(str, Enum):
    PDF = 'PDF'
    PDF_EMBEDDED_JPG = 'PDF_EMBEDDED_JPG'
    IMAGE_JPG = 'IMAGE_JPG'
    IMAGE_JPG_TEXT = 'IMAGE_JPG_TEXT'
    IMAGE_PNG = 'IMAGE_PNG'
    IMAGE_PNG_TEXT = 'IMAGE_PNG_TEXT'
    NOT_SUPPORT = 'NOT_SUPPORT'

class ResourceStatus(str, Enum):
    PREURL = 'PREURL'
    UPLOAD = 'UPLOAD'
    COPY_S3 = 'COPY_S3'
    CLASSIFIED = 'CLASSIFIED'
    VERIFICATIONS_PENDING = 'VERIFICATIONS_PENDING'
    VERIFICATIONS_COMPLETE = 'VERIFICATIONS_COMPLETE'
    ERROR = 'ERROR'

class PdfImagesExtracted(Entity):

    def __init__(
            self,
            s3Bucket: str,
            s3Key: str,
            filename: str,
            sha512: str):
        self.s3Bucket = s3Bucket
        self.s3Key = s3Key
        self.filename = filename
        self.sha512 = sha512


def __init__(
        self,
        s3Data: S3Data,
        attribute: Attribute,
        eventType: EventType,
        contentType: str,
        classifiedType: ClassifiedType,
        eventId: str,
        errorMessage: str,
        resourceStatus: ResourceStatus,
        pdfImagesExtracted: Sequence[PdfImagesExtracted],
        parentResources: Sequence[str]):
    self.s3Data = s3Data
    self.attribute = attribute
    self.eventType = eventType
    self.contentType = contentType
    self.classifiedType = classifiedType
    self.eventId = eventId
    self.errorMessage = errorMessage
    self.resourceStatus = resourceStatus
    self.pdfImagesExtracted = pdfImagesExtracted
    self.parentResources = parentResources

this properties are not required self.classifiedType = classifiedType self.eventId = eventId self.errorMessage = errorMessage self.resourceStatus = resourceStatus self.pdfImagesExtracted = pdfImagesExtracted self.parentResources = parentResources

the selft.s3Data nested is not type S3Data

the seft.pdfImagesExtracted the item is not type PdfImagesExtracted

so i want add some new part

tornabene avatar Nov 30 '23 13:11 tornabene

I will push the solution here https://github.com/tornabene/python-template

ag asyncapi.yaml @tornabene.org/[email protected] -o python

tornabene avatar Dec 04 '23 13:12 tornabene