title: How to write a nested object in Swagger 3.0 for components
body: <p>So I am working on developing the components yaml file in the Data Transfer Object files so I can then reference them.</p>
  <p>This is what I have so far:</p>
  <pre><code>/**
  * @openapi
  * components:
  *   schemas:
  *     VerifiedEmailAddressDto:
  *       type: object
  *       required:
  *         - email
  *       properties:
  *         _type:
  *           type: string
  *         email:
  *           type: string
  *           description: a users email.
  *         reset:
  *           type: boolean
  *         passwordRules:
  *           type: object
  *           properties:
  *             minLength:
  *               type: number
  *             maxLength:
  *               type: number
  *             minRequiredUppercase:
  *               type: number
  *       example:
  *         _type: VerifiedEmailAddressDto
  *         email: pablo+test_pab001@alunacare.com
  *         reset: false
  *         passwordRules:
  */
  export class VerifiedEmailAddressDto {
    readonly _type = &quot;VerifiedEmailAddressDto&quot;;
    readonly email: string;
    readonly reset: boolean;
    readonly passwordRules: { minLength: number; maxLength: number; minRequiredUppercase: number; minRequiredLowerCase: number; minRequiredSymbols: number };
  
    constructor(email: string, reset: boolean, passwordRules: { minLength: number; maxLength: number; minRequiredUppercase: number; minRequiredLowerCase: number; minRequiredSymbols: number }) {
     this.email = email;
     this.reset = reset;
     this.passwordRules = passwordRules;
    }
  }
  </code></pre>
  <p>That last property of <code>passwordRules</code> is an object inside this object. So it's a nested object, but what I have so far, does not give me this:</p>
  <pre><code>{
   &quot;_type&quot;: &quot;VerifiedEmailAddressDto&quot;,
   &quot;email&quot;: &quot;pablo+test_pab001@alunacare.com&quot;,
   &quot;reset&quot;: false,
   &quot;passwordRules&quot;: {
     &quot;minLength&quot;: 8,
     &quot;maxLength&quot;: 25,
     &quot;minRequiredUppercase&quot;: 1,
     &quot;minRequiredLowerCase&quot;: 1,
     &quot;minRequiredSymbols&quot;: 0
    }
  }
  </code></pre>
  <p>But honestly I am not sure how to complete this, I assume that this part:</p>
  <pre><code>*         passwordRules:
  *           type: object
  *           properties:
  *             minLength:
  *               type: number
  *             maxLength:
  *               type: number
  *             minRequiredUppercase:
  *               type: number
  </code></pre>
  <p>is correct, but what to offer in the example is what I am stuck on and perhaps maybe even the above in this case might not be correct.</p>
  <p>The idea is so I can eventually property reference it here:</p>
  <pre><code>/**
  * @openapi
  * /api/v2/auth/check_mail:
  *   post:
  *     tags: [Auth]
  *     description: This endpoint checks to see if an email is unique or is in use.
  *     requestBody:
  *       required: true
  *       content:
  *         application/json:
  *           schema:
  *           type: object
  *           $ref: '#/components/schemas/VerifiedEmailAddressDto'
  *     responses:
  *       201:
  *         description: Get permissions.
  *         content:
  *           application/json:
  *             schema:
  *             $ref: '#/components/schemas/VerifiedEmailAddressDto'
  */
  this.app.post(p().api.v2.auth.check_email.$url, [
  // TODO restrict number of queries by IP by period of time.
  authMiddleware.validateEmailQuery,
  credentialsController.verifyEmailAddress
  ]);
  </code></pre>
  <p>So I am able to get an empty object to appear for <code>passwordRules</code> like so:</p>
  <pre><code>/**
  * @openapi
  * components:
  *   schemas:
  *     VerifiedEmailAddressDto:
  *       type: object
  *       required:
  *         - email
  *       properties:
  *         _type:
  *           type: string
  *         email:
  *           type: string
  *           description: a users email.
  *         reset:
  *           type: boolean
  *         passwordRules:
  *           type: object
  *           properties:
  *             minLength:
  *               type: number
  *             maxLength:
  *               type: number
  *             minRequiredUppercase:
  *               type: number
  *       example:
  *         _type: VerifiedEmailAddressDto
  *         email: pablo+test_pab001@alunacare.com
  *         reset: false
  *         passwordRules: {}
  */
  export class VerifiedEmailAddressDto {
    readonly _type = &quot;VerifiedEmailAddressDto&quot;;
    readonly email: string;
    readonly reset: boolean;
    readonly passwordRules: { minLength: number; maxLength: number; minRequiredUppercase: number; minRequiredLowerCase: number; minRequiredSymbols: number };
  
    constructor(email: string, reset: boolean, passwordRules: { minLength: number; maxLength: number; minRequiredUppercase: number; minRequiredLowerCase: number; minRequiredSymbols: number }) {
     this.email = email;
     this.reset = reset;
     this.passwordRules = passwordRules;
    }
  }
  </code></pre>
  <p>but if I try to add its properties within the object like so:</p>
  <pre><code>passwordRules: {
    minLength: 8
    maxLength: 25
  }
  </code></pre>
  <p>I get nothing, if I try to put the examples in like so:</p>
  <pre><code>  *         passwordRules:
      *           type: object
      *           properties:
      *             minLength:
      *               type: number
      *               example: 8
      *             maxLength:
      *               type: number
      *               example: 25
      *             minRequiredUppercase:
      *               type: number
      *               example: 1
      *       example:
      *         _type: VerifiedEmailAddressDto
      *         email: pablo+test_pab001@alunacare.com
      *         reset: false
      *         passwordRules: {}
  </code></pre>
  <p>I still get nothing.</p>