title: How to generate Python dictionary from OpenAPI 3 YAML file?
body: <p>Is there a Python 3 package or code snippet that can read an OpenAPI 3 YAML file and convert it to a Python dictionary?</p>
  <p>This is an example of the contents in an OpenAPI 3 YAML file</p>
  <pre><code>openapi: 3.0.0
  servers:
      url: https://localhost/api
  paths:
    /user/{userId}:
      get:
        summary: Get a user by ID
        parameters:
          - in: path
            name: userId
        responses:
          '200':
            description: Successful operation
            content:
              application/json:
                schema:
                  $ref: '#/components/schemas/User'
  components:
    schemas:
      User:
        type: object
        properties:
          id:
            type: integer
          name:
            $ref: '#/components/schemas/UserFullName'
          age:
            type: integer
      UserFullName:
        type: object
        properties:
          firstName:
            type: string
          lastName:
            type: string
  </code></pre>
  <p>I want the package/code to generate a Python dictionary looking something like this</p>
  <pre><code>{
    &quot;/user/{userId}&quot;: {
      &quot;get&quot;: {
        &quot;200&quot;: {
          &quot;id&quot;: &quot;integer&quot;,
          &quot;name&quot;: {
            &quot;firstName&quot;: &quot;string&quot;,
            &quot;lastName&quot;: &quot;string&quot;
          }
          &quot;age&quot; &quot;integer&quot;
        }
      }
    }
  }
  </code></pre>
  <p>------ Edit -----</p>
  <p>I have tried PyYaml, however, it is not returning what I am expecting.</p>
  <p>I am expecting the '$ref' key-value pair to act as a string interpolation like this:</p>
  <pre><code>{
     &quot;id&quot;:0,
     &quot;name&quot;:{
        &quot;firstName&quot;:&quot;string&quot;,
        &quot;lastName&quot;:&quot;string&quot;
     },
     &quot;age&quot;:0
  }
  </code></pre>
  <p>Instead, PyYaml is returning this:</p>
  <pre><code>{
    &quot;id&quot;:0,
    &quot;name&quot;: {
      &quot;$ref&quot;: &quot;#/components/schemas/UserFullName&quot;
    },
    &quot;age&quot;:0
  }
  </code></pre>