title: List of object attributes in pydantic model
body: <p>I use Fast API to create a web service.</p>
  <p>There are following sqlAlchemy models:</p>
  <pre><code>class User(Base):
      __tablename__ = 'user'
      account_name = Column(String, primary_key=True, index=True, unique=True)
      email = Column(String, unique=True, index=True, nullable=False)
      roles = relationship(&quot;UserRole&quot;, back_populates=&quot;users&quot;, lazy=False, uselist=True)
  
  
  class UserRole(Base):
      __tablename__ = 'user_role'
      __table_args__ = (UniqueConstraint('role_name', 'user_name', name='user_role_uc'),)
      role_name = Column(String, ForeignKey('role.name'), primary_key=True)
      user_name = Column(String, ForeignKey('user.account_name'), primary_key=True)
      users = relationship(&quot;User&quot;, back_populates=&quot;roles&quot;)
  </code></pre>
  <p>Pydantic schemas are below:</p>
  <pre><code>class UserRole(BaseModel):
      role_name: str
  
      class Config:
          orm_mode = True
  
  
  class UserBase(BaseModel):
      account_name: str
      email: EmailStr
      roles: List[UserRole] = []
  
      class Config:
          orm_mode = True
  </code></pre>
  <p>What I have now is:</p>
  <pre><code>{
    &quot;account_name&quot;: &quot;Test.Test&quot;,
    &quot;email&quot;: &quot;Test.Test@test.com&quot;,
    &quot;roles&quot;: [
      {
        &quot;role_name&quot;: &quot;all:admin&quot;
      },
      {
        &quot;role_name&quot;: &quot;all:read&quot;
      }
    ]
  }
  </code></pre>
  <p>What I want to achieve is to get user from api in following structure:</p>
  <pre><code>{
    &quot;account_name&quot;: &quot;Test.Test&quot;,
    &quot;email&quot;: &quot;Test.Test@test.com&quot;,
    &quot;roles&quot;: [
      &quot;all:admin&quot;,
      &quot;all:read&quot;
    ]
  }
  </code></pre>
  <p>Is that possible? How should I change schemas to get this?</p>