Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to define a data class with list of elements? #12

Closed
rsoika opened this issue May 5, 2024 · 1 comment
Closed

How to define a data class with list of elements? #12

rsoika opened this issue May 5, 2024 · 1 comment

Comments

@rsoika
Copy link

rsoika commented May 5, 2024

Hi,
my goal is to define a data class with fastapi-xml that a request body can look like this:

<?xml version="1.0" encoding="UTF-8"?>
<PromptDefinitionEmbeddings>
	<model>abc</model>
	<prompt>What is your name?</prompt>
	<embeddings>
		<embeddingData>embedding1</embeddingData>
		<embeddingData>embedding2</embeddingData>
	</embeddings>
</PromptDefinitionEmbeddings>

My current dataClass looks like this:

@dataclass
class PromptDefinition:

    model: str = field(
        metadata={
            "examples": ["mistral-7b-instruct-v0.2.Q3_K_S.gguf"],
            "name": "model", 
            "type": "Element"
        }
    )    

    prompt: str = field(
        metadata={
            "examples": ["What is the Imixs-Workflow engine?"],
            "name": "prompt", 
            "type": "Element"
        }
    )  

But I did not find out how to define a tag list in fastapi-xml. Can someone help me?

@cercide
Copy link
Owner

cercide commented May 12, 2024

Hi @rsoika,
xsdata has a pseudo wrapper Element. There is a related issue: tefra/xsdata#710
Likewise, this is the doc reference: https://xsdata.readthedocs.io/en/latest/models/fields/#wrapper

I hope this adresses your issue.

@cercide cercide closed this as completed Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants