Repository: softprops/openapi (language: rust)

Issue:
Support for OpenAPI 3.0

These are the changes:
https://blog.readme.io/an-example-filled-guide-to-swagger-3-2/


Discussion / hints:
Good idea. Ill look into this after settling on type interfaces for version 2
I'm exploring OpenAPI v3 for some project, and decided to try to implement the spec.

It's not complete (it's missing many objects from the spec) but I think it's in a working state. I can deserialize and serialize back to yml a "small" API (<250 lines) with almost no loss, mostly formatting (quotes or not around strings, a `---` at the top of the file, fields ordering, etc.).

I wrote a small dumb bash script to check which objects are missing an struct by comparing with the table of content of the spec. Here's the output:
```
./find_missing_objects.sh
OpenAPI NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#oasObject
Server Variable NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#serverVariableObject
Components NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#componentsObject
Paths NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#pathsObject
External Documentation NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#externalDocumentationObject
Responses NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#responsesObject
Link NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#linkObject
Reference NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#referenceObject
Discriminator NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#discriminatorObject
XML NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#xmlObject
Security Scheme NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#securitySchemeObject
OAuth Flows NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#oauthFlowsObject
OAuth Flow NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#oauthFlowObject
Security Requirement NOT implemented! See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#securityRequirementObject
```

I'm not sure how to test/validate the code though. The only test in the original crate is a deserialization test on the couple of OpenAPI v3 examples. As with my manual validation above, re-serialization can't really be used to compare with original since ordering and quoting can change. I guess the reference yml files could be split into smaller chunks to test specific structs...

I would like to add proper referencing (#12) but for now I use strings.

I also have a small check for the API version (#8), but it can only be checked _after_ deserialization. So if one tries to deserialize an unsupported version, it will fail at the deserialization step, not the at the validation.

I haven't forked this repo (started a new one instead, not even on github). I though it was easier to start from scratch and add what was required for v3, importing from this repo when it was making sense. As such it could probably be merged back into this repo.

Let me know if it could be useful!
I've actually found a way to solve both the field ordering issue and validating that features are implemented.

For this, I do both of these conversions:
1. File -> `String` -> `serde_yaml::Value` -> `serde_json::Value` -> `String` (using `serde_json::to_string_pretty`)
1. File -> `Spec` -> `serde_json::Value` -> `String` (using `serde_json::to_string_pretty`)
and compare the result. Fields will have the same ordering (the one dictated by `serde_json`).

Also, missing features will clearly be shown as missing fields in the second string above.

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 48d066c..8cc541c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,3 +15,6 @@ serde_derive = "1.0"
 serde_json = "1.0"
 serde_yaml = "0.7"
 error-chain = "0.10"
+semver = "0.9.0"
+url = "1.6.0"
+url_serde = "0.2.0"
diff --git a/data/k8s.json b/data/v2/k8s.json
similarity index 100%
rename from data/k8s.json
rename to data/v2/k8s.json
diff --git a/data/petstore-simple.yaml b/data/v2/petstore-simple.yaml
similarity index 100%
rename from data/petstore-simple.yaml
rename to data/v2/petstore-simple.yaml
diff --git a/data/petstore_minimal.yaml b/data/v2/petstore_minimal.yaml
similarity index 100%
rename from data/petstore_minimal.yaml
rename to data/v2/petstore_minimal.yaml
diff --git a/data/rocks.yaml b/data/v2/rocks.yaml
similarity index 100%
rename from data/rocks.yaml
rename to data/v2/rocks.yaml
diff --git a/data/uber.yaml b/data/v2/uber.yaml
similarity index 100%
rename from data/uber.yaml
rename to data/v2/uber.yaml
diff --git a/data/v3.0/api-with-examples.yaml b/data/v3.0/api-with-examples.yaml
new file mode 100644
index 0000000..dd42b0e
--- /dev/null
+++ b/data/v3.0/api-with-examples.yaml
@@ -0,0 +1,167 @@
+openapi: "3.0.0"
+info:
+  title: Simple API overview
+  version: v2
+paths:
+  /:
+    get:
+      operationId: listVersionsv2
+      summary: List API versions
+      responses:
+        '200':
+          description: |-
+            200 response
+          content:
+            application/json:
+              examples: 
+                foo:
+                  value: {
+                    "versions": [
+                        {
+                            "status": "CURRENT",
+                            "updated": "2011-01-21T11:33:21Z",
+                            "id": "v2.0",
+                            "links": [
+                                {
+                                    "href": "http://127.0.0.1:8774/v2/",
+                                    "rel": "self"
+                                }
+                            ]
+                        },
+                        {
+                            "status": "EXPERIMENTAL",
+                            "updated": "2013-07-23T11:33:21Z",
+                            "id": "v3.0",
+                            "links": [
+                                {
+                                    "href": "http://127.0.0.1:8774/v3/",
+                                    "rel": "self"
+                                }
+                            ]
+                        }
+                    ]
+                 }
+        '300':
+          description: |-
+            300 response
+          content:
+            application/json: 
+              examples: 
+                foo:
+                  value: |
+                   {
+                    "versions": [
+                          {
+                            "status": "CURRENT",
+                            "updated": "2011-01-21T11:33:21Z",
+                            "id": "v2.0",
+                            "links": [
+                                {
+                                    "href": "http://127.0.0.1:8774/v2/",
+                                    "rel": "self"
+                                }
+                            ]
+                        },
+                        {
+                            "status": "EXPERIMENTAL",
+                            "updated": "2013-07-23T11:33:21Z",
+                            "id": "v3.0",
+                            "links": [
+                                {
+                                    "href": "http://127.0.0.1:8774/v3/",
+                                    "rel": "self"
+                                }
+                            ]
+                        }
+                    ]
+                   }
+  /v2:
+    get:
+      operationId: getVersionDetailsv2
+      summary: Show API version details
+      responses:
+        '200':
+          description: |-
+            200 response
+          content:
+            application/json: 
+              examples:
+                foo:
+                  value: {
+                    "version": {
+                      "status": "CURRENT",
+                      "updated": "2011-01-21T11:33:21Z",
+                      "media-types": [
+                          {
+                              "base": "application/xml",
+                              "type": "application/vnd.openstack.compute+xml;version=2"
+                          },
+                          {
+                              "base": "application/json",
+                              "type": "application/vnd.openstack.compute+json;version=2"
+                          }
+                      ],
+                      "id": "v2.0",
+                      "links": [
+                          {
+                              "href": "http://127.0.0.1:8774/v2/",
+                              "rel": "self"
+                          },
+                          {
+                              "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
+                              "type": "application/pdf",
+                              "rel": "describedby"
+                          },
+                          {
+                              "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
+                              "type": "application/vnd.sun.wadl+xml",
+                              "rel": "describedby"
+                          },
+                          {
+                            "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
+                            "type": "application/vnd.sun.wadl+xml",
+                            "rel": "describedby"
+                          }
+                      ]
+                    }
+                  }
+        '203':
+          description: |-
+            203 response
+          content:
+            application/json: 
+              examples:
+                foo:
+                  value: {
+                    "version": {
+                      "status": "CURRENT",
+                      "updated": "2011-01-21T11:33:21Z",
+                      "media-types": [
+                          {
+                              "base": "application/xml",
+                              "type": "application/vnd.openstack.compute+xml;version=2"
+                          },
+                          {
+                              "base": "application/json",
+                              "type": "application/vnd.openstack.compute+json;version=2"
+                          }
+                      ],
+                      "id": "v2.0",
+                      "links": [
+                          {
+                              "href": "http://23.253.228.211:8774/v2/",
+                              "rel": "self"
+                          },
+                          {
+                              "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
+                              "type": "application/pdf",
+                              "rel": "describedby"
+                          },
+                          {
+                              "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
+                              "type": "application/vnd.sun.wadl+xml",
+                              "rel": "describedby"
+                          }
+                      ]
+                    }
+                  }
diff --git a/data/v3.0/callback-example.yaml b/data/v3.0/callback-example.yaml
new file mode 100644
index 0000000..1622bd0
--- /dev/null
+++ b/data/v3.0/callback-example.yaml
@@ -0,0 +1,60 @@
+openapi: 3.0.0
+info:
+  title: Callback Example
+  version: 1.0.0
+paths:
+  /streams:
+    post:
+      description: subscribes a client to receive out-of-band data
+      parameters:
+        - name: callbackUrl
+          in: query
+          required: true
+          description: |
+            the location where data will be sent.  Must be network accessible
+            by the source server
+          schema:
+            type: string
+            format: uri
+            example: https://tonys-server.com
+      responses:
+        '201':
+          description: subscription successfully created
+          content:
+            application/json:
+              schema:
+                description: subscription information
+                required:
+                  - subscriptionId
+                properties:
+                  subscriptionId:
+                    description: this unique identifier allows management of the subscription
+                    type: string
+                    example: 2531329f-fb09-4ef7-887e-84e648214436
+      callbacks:
+        # the name `onData` is a convenience locator
+        onData:
+          # when data is sent, it will be sent to the `callbackUrl` provided
+          # when making the subscription PLUS the suffix `/data`
+          '{$request.query.callbackUrl}/data':
+            post:
+              requestBody:
+                description: subscription payload
+                content:
+                  application/json:
+                    schema:
+                      properties:
+                        timestamp:
+                          type: string
+                          format: date-time
+                        userData:
+                          type: string
+              responses:
+                '202':
+                  description: |
+                    Your server implementation should return this HTTP status code
+                    if the data was received successfully
+                '204':
+                  description: |
+                    Your server should return this HTTP status code if no longer interested
+                    in further updates
diff --git a/data/v3.0/link-example.yaml b/data/v3.0/link-example.yaml
new file mode 100644
index 0000000..5837d70
--- /dev/null
+++ b/data/v3.0/link-example.yaml
@@ -0,0 +1,203 @@
+openapi: 3.0.0
+info: 
+  title: Link Example
+  version: 1.0.0
+paths: 
+  /2.0/users/{username}: 
+    get: 
+      operationId: getUserByName
+      parameters: 
+      - name: username
+        in: path
+        required: true
+        schema:
+          type: string
+      responses: 
+        '200':
+          description: The User
+          content:
+            application/json:
+              schema: 
+                $ref: '#/components/schemas/user'
+          links:
+            userRepositories:
+              $ref: '#/components/links/UserRepositories'
+  /2.0/repositories/{username}:
+    get:
+      operationId: getRepositoriesByOwner
+      parameters:
+        - name: username
+          in: path
+          required: true
+          schema:
+            type: string
+      responses:
+        '200':
+          description: repositories owned by the supplied user
+          content: 
+            application/json:
+              schema:
+                type: array
+                items:
+                  $ref: '#/components/schemas/repository'
+          links:
+            userRepository:
+              $ref: '#/components/links/UserRepository'
+  /2.0/repositories/{username}/{slug}: 
+    get: 
+      operationId: getRepository
+      parameters: 
+        - name: username
+          in: path
+          required: true
+          schema:
+            type: string
+        - name: slug
+          in: path
+          required: true
+          schema:
+            type: string
+      responses: 
+        '200':
+          description: The repository
+          content:
+              application/json: 
+                schema: 
+                  $ref: '#/components/schemas/repository'
+          links:
+            repositoryPullRequests:
+              $ref: '#/components/links/RepositoryPullRequests'
+  /2.0/repositories/{username}/{slug}/pullrequests: 
+    get: 
+      operationId: getPullRequestsByRepository
+      parameters: 
+      - name: username
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: slug
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: state
+        in: query
+        schema:
+          type: string
+          enum: 
+            - open
+            - merged
+            - declined
+      responses: 
+        '200':
+          description: an array of pull request objects
+          content:
+            application/json: 
+              schema: 
+                type: array
+                items: 
+                  $ref: '#/components/schemas/pullrequest'
+  /2.0/repositories/{username}/{slug}/pullrequests/{pid}: 
+    get: 
+      operationId: getPullRequestsById
+      parameters: 
+      - name: username
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: slug
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: pid
+        in: path
+        required: true
+        schema:
+          type: string
+      responses: 
+        '200':
+          description: a pull request object
+          content:
+            application/json: 
+              schema: 
+                $ref: '#/components/schemas/pullrequest'
+          links:
+            pullRequestMerge:
+              $ref: '#/components/links/PullRequestMerge'
+  /2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge: 
+    post: 
+      operationId: mergePullRequest
+      parameters: 
+      - name: username
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: slug
+        in: path
+        required: true
+        schema:
+          type: string
+      - name: pid
+        in: path
+        required: true
+        schema:
+          type: string
+      responses: 
+        '204':
+          description: the PR was successfully merged
+components:
+  links:
+    UserRepositories:
+      # returns array of '#/components/schemas/repository'
+      operationId: getRepositoriesByOwner
+      parameters:
+        username: $response.body#/username
+    UserRepository:
+      # returns '#/components/schemas/repository'
+      operationId: getRepository
+      parameters:
+        username: $response.body#/owner/username
+        slug: $response.body#/slug
+    RepositoryPullRequests:
+      # returns '#/components/schemas/pullrequest'
+      operationId: getPullRequestsByRepository
+      parameters: 
+          username: $response.body#/owner/username
+          slug: $response.body#/slug
+    PullRequestMerge:
+      # executes /2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge
+      operationId: mergePullRequest
+      parameters:
+        username: $response.body#/author/username
+        slug: $response.body#/repository/slug
+        pid: $response.body#/id
+  schemas: 
+    user: 
+      type: object
+      properties: 
+        username: 
+          type: string
+        uuid: 
+          type: string
+    repository: 
+      type: object
+      properties: 
+        slug: 
+          type: string
+        owner: 
+          $ref: '#/components/schemas/user'
+    pullrequest: 
+      type: object
+      properties: 
+        id: 
+          type: integer
+        title: 
+          type: string
+        repository: 
+          $ref: '#/components/schemas/repository'
+        author: 
+          $ref: '#/components/schemas/user'
diff --git a/data/v3.0/petstore-expanded.yaml b/data/v3.0/petstore-expanded.yaml
new file mode 100644
index 0000000..e8c0fe5
--- /dev/null
+++ b/data/v3.0/petstore-expanded.yaml
@@ -0,0 +1,155 @@
+openapi: "3.0.0"
+info:
+  version: 1.0.0
+  title: Swagger Petstore
+  description: A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification
+  termsOfService: http://swagger.io/terms/
+  contact:
+    name: Swagger API Team
+    email: foo@example.com
+    url: http://madskristensen.net
+  license:
+    name: MIT
+    url: http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
+servers:
+  - url: http://petstore.swagger.io/api
+paths:
+  /pets:
+    get:
+      description: |
+        Returns all pets from the system that the user has access to
+        Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.
+
+        Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.
+      operationId: findPets
+      parameters:
+        - name: tags
+          in: query
+          description: tags to filter by
+          required: false
+          style: form
+          schema:
+            type: array
+            items:
+              type: string
+        - name: limit
+          in: query
+          description: maximum number of results to return
+          required: false
+          schema:
+            type: integer
+            format: int32
+      responses:
+        '200':
+          description: pet response
+          content:
+            application/json:
+              schema:
+                type: array
+                items:
+                  $ref: '#/components/schemas/Pet'
+        default:
+          description: unexpected error
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/Error'
+    post:
+      description: Creates a new pet in the store.  Duplicates are allowed
+      operationId: addPet
+      requestBody:
+        description: Pet to add to the store
+        required: true
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/NewPet'
+      responses:
+        '200':
+          description: pet response
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/Pet'
+        default:
+          description: unexpected error
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/Error'
+  /pets/{id}:
+    get:
+      description: Returns a user based on a single ID, if the user does not have access to the pet
+      operationId: find pet by id
+      parameters:
+        - name: id
+          in: path
+          description: ID of pet to fetch
+          required: true
+          schema:
+            type: integer
+            format: int64
+      responses:
+        '200':
+          description: pet response
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/Pet'
+        default:
+          description: unexpected error
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/Error'
+    delete:
+      description: deletes a single pet based on the ID supplied
+      operationId: deletePet
+      parameters:
+        - name: id
+          in: path
+          description: ID of pet to delete
+          required: true
+          schema:
+            type: integer
+            format: int64
+      responses:
+        '204':
+          description: pet deleted
+        default:
+          description: unexpected error
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/Error'
+components:
+  schemas:
+    Pet:
+      allOf:
+        - $ref: '#/components/schemas/NewPet'
+        - required:
+          - id
+          properties:
+            id:
+              type: integer
+              format: int64
+
+    NewPet:
+      required:
+        - name  
+      properties:
+        name:
+          type: string
+        tag:
+          type: string    
+
+    Error:
+      required:
+        - code
+        - message
+      properties:
+        code:
+          type: integer
+          format: int32
+        message:
+          type: string
diff --git a/data/v3.0/petstore.yaml b/data/v3.0/petstore.yaml
new file mode 100644
index 0000000..5fdfba9
--- /dev/null
+++ b/data/v3.0/petstore.yaml
@@ -0,0 +1,109 @@
+openapi: "3.0.0"
+info:
+  version: 1.0.0
+  title: Swagger Petstore
+  license:
+    name: MIT
+servers:
+  - url: http://petstore.swagger.io/v1
+paths:
+  /pets:
+    get:
+      summary: List all pets
+      operationId: listPets
+      tags:
+        - pets
+      parameters:
+        - name: limit
+          in: query
+          description: How many items to return at one time (max 100)
+          required: false
+          schema:
+            type: integer
+            format: int32
+      responses:
+        '200':
+          description: An paged array of pets
+          headers:
+            x-next:
+              description: A link to the next page of responses
+              schema:
+                type: string
+          content:
+            application/json:    
+              schema:
+                $ref: "#/components/schemas/Pets"
+        default:
+          description: unexpected error
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Error"
+    post:
+      summary: Create a pet
+      operationId: createPets
+      tags:
+        - pets
+      responses:
+        '201':
+          description: Null response
+        default:
+          description: unexpected error
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Error"
+  /pets/{petId}:
+    get:
+      summary: Info for a specific pet
+      operationId: showPetById
+      tags:
+        - pets
+      parameters:
+        - name: petId
+          in: path
+          required: true
+          description: The id of the pet to retrieve
+          schema:
+            type: string
+      responses:
+        '200':
+          description: Expected response to a valid request
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Pets"
+        default:
+          description: unexpected error
+          content:
+            application/json:
+              schema:
+                $ref: "#/components/schemas/Error"
+components:
+  schemas:
+    Pet:
+      required:
+        - id
+        - name
+      properties:
+        id:
+          type: integer
+          format: int64
+        name:
+          type: string
+        tag:
+          type: string
+    Pets:
+      type: array
+      items:
+        $ref: "#/components/schemas/Pet"
+    Error:
+      required:
+        - code
+        - message
+      properties:
+        code:
+          type: integer
+          format: int32
+        message:
+          type: string
diff --git a/data/v3.0/uspto.yaml b/data/v3.0/uspto.yaml
new file mode 100644
index 0000000..774ca52
--- /dev/null
+++ b/data/v3.0/uspto.yaml
@@ -0,0 +1,210 @@
+openapi: 3.0.0
+servers:
+  - url: '{scheme}://developer.uspto.gov/ds-api'
+    variables:
+      scheme:
+        description: 'The Data Set API is accessible via https and http'
+        enum:
+          - 'https'
+          - 'http'
+        default: 'https'
+info:
+  description: >-
+    The Data Set API (DSAPI) allows the public users to discover and search
+    USPTO exported data sets. This is a generic API that allows USPTO users to
+    make any CSV based data files searchable through API. With the help of GET
+    call, it returns the list of data fields that are searchable. With the help
+    of POST call, data can be fetched based on the filters on the field names.
+    Please note that POST call is used to search the actual data. The reason for
+    the POST call is that it allows users to specify any complex search criteria
+    without worry about the GET size limitations as well as encoding of the
+    input parameters.
+  version: 1.0.0
+  title: USPTO Data Set API
+  contact:
+    name: Open Data Portal
+    url: 'https://developer.uspto.gov'
+    email: developer@uspto.gov
+tags:
+  - name: metadata
+    description: Find out about the data sets
+  - name: search
+    description: Search a data set
+paths:
+  /:
+    get:
+      tags:
+        - metadata
+      operationId: list-data-sets
+      summary: List available data sets
+      responses:
+        '200':
+          description: Returns a list of data sets
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/dataSetList'
+              example:
+                {
+                  "total": 2,
+                  "apis": [
+                    {
+                      "apiKey": "oa_citations",
+                      "apiVersionNumber": "v1",
+                      "apiUrl": "https://developer.uspto.gov/ds-api/oa_citations/v1/fields",
+                      "apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/oa_citations.json"
+                    },
+                    {
+                      "apiKey": "cancer_moonshot",
+                      "apiVersionNumber": "v1",
+                      "apiUrl": "https://developer.uspto.gov/ds-api/cancer_moonshot/v1/fields",
+                      "apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/cancer_moonshot.json"
+                    }
+                  ]
+                }
+  /{dataset}/{version}/fields:
+    get:
+      tags:
+        - metadata
+      summary: >-
+        Provides the general information about the API and the list of fields
+        that can be used to query the dataset.
+      description: >-
+        This GET API returns the list of all the searchable field names that are
+        in the oa_citations. Please see the 'fields' attribute which returns an
+        array of field names. Each field or a combination of fields can be
+        searched using the syntax options shown below.
+      operationId: list-searchable-fields
+      parameters:
+        - name: dataset
+          in: path
+          description: 'Name of the dataset. In this case, the default value is oa_citations'
+          required: true
+          schema:
+            type: string
+            default: oa_citations
+        - name: version
+          in: path
+          description: Version of the dataset.
+          required: true
+          schema:
+            type: string
+            default: v1
+      responses:
+        '200':
+          description: >-
+            The dataset api for the given version is found and it is accessible
+            to consume.
+          content:
+            application/json:
+              schema:
+                type: string
+        '404':
+          description: >-
+            The combination of dataset name and version is not found in the
+            system or it is not published yet to be consumed by public.
+          content:
+            application/json:
+              schema:
+                type: string
+  /{dataset}/{version}/records:
+    post:
+      tags:
+        - search
+      summary: >-
+        Provides search capability for the data set with the given search
+        criteria.
+      description: >-
+        This API is based on Solr/Lucense Search. The data is indexed using
+        SOLR. This GET API returns the list of all the searchable field names
+        that are in the Solr Index. Please see the 'fields' attribute which
+        returns an array of field names. Each field or a combination of fields
+        can be searched using the Solr/Lucene Syntax. Please refer
+        https://lucene.apache.org/core/3_6_2/queryparsersyntax.html#Overview for
+        the query syntax. List of field names that are searchable can be
+        determined using above GET api.
+      operationId: perform-search
+      parameters:
+        - name: version
+          in: path
+          description: Version of the dataset.
+          required: true
+          schema:
+            type: string
+            default: v1
+        - name: dataset
+          in: path
+          description: 'Name of the dataset. In this case, the default value is oa_citations'
+          required: true
+          schema:
+            type: string
+            default: oa_citations
+      responses:
+        '200':
+          description: successful operation
+          content:
+            application/json:
+              schema:
+                type: array
+                items:
+                  type: object
+                  additionalProperties:
+                    type: object
+        '404':
+          description: No matching record found for the given criteria.
+      requestBody:
+        content:
+          application/x-www-form-urlencoded:
+            schema:
+              type: object
+              properties:
+                criteria:
+                  description: >-
+                    Uses Lucene Query Syntax in the format of
+                    propertyName:value, propertyName:[num1 TO num2] and date
+                    range format: propertyName:[yyyyMMdd TO yyyyMMdd]. In the
+                    response please see the 'docs' element which has the list of
+                    record objects. Each record structure would consist of all
+                    the fields and their corresponding values.
+                  type: string
+                  default: '*:*'
+                start:
+                  description: Starting record number. Default value is 0.
+                  type: integer
+                  default: 0
+                rows:
+                  description: >-
+                    Specify number of rows to be returned. If you run the search
+                    with default values, in the response you will see 'numFound'
+                    attribute which will tell the number of records available in
+                    the dataset.
+                  type: integer
+                  default: 100
+              required:
+                - criteria
+components:
+  schemas:
+    dataSetList:
+      type: object
+      properties:
+        total:
+          type: integer
+        apis:
+          type: array
+          items:
+            type: object
+            properties:
+              apiKey:
+                type: string
+                description: To be used as a dataset parameter value
+              apiVersionNumber:
+                type: string
+                description: To be used as a version parameter value
+              apiUrl:
+                type: string
+                format: uriref
+                description: "The URL describing the dataset's fields"
+              apiDocumentationUrl:
+                type: string
+                format: uriref
+                description: A URL to the API console for each API
diff --git a/src/lib.rs b/src/lib.rs
index 837eb0b..3ce658f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -36,13 +36,19 @@ extern crate serde_derive;
 extern crate serde;
 extern crate serde_json;
 extern crate serde_yaml;
+extern crate url;
+extern crate url_serde;
+extern crate semver;
 
 use std::fs;
 use std::io::Read;
 use std::path::Path;
 
-mod schema;
-pub use schema::*;
+pub mod v2;
+pub mod v3_0;
+
+const MINIMUM_OPENAPI30_VERSION: &str = ">= 3.0";
+
 
 /// errors that openapi functions may return
 pub mod errors {
@@ -51,13 +57,41 @@ pub mod errors {
             Io(::std::io::Error);
             Yaml(::serde_yaml::Error);
             Serialize(::serde_json::Error);
+            SemVerError(::semver::SemVerError);
+        }
+
+        errors {
+            UnsupportedSpecFileVersion(version: ::semver::Version) {
+                description("Unsupported spec file version")
+                display("Unsupported spec file version ({}). Expected {}", version, ::MINIMUM_OPENAPI30_VERSION)
+            }
         }
     }
 }
 pub use errors::{Result, ResultExt};
 
+/// Supported versions of the OpenApi.
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+#[serde(untagged)]
+pub enum OpenApi {
+    /// Version 2.0 of the OpenApi specification.
+    ///
+    /// Refer to the official
+    /// [specification](https://github.com/OAI/OpenAPI-Specification/blob/0dd79f6/versions/2.0.md)
+    /// for more information.
+    V2(v2::Spec),
+
+    /// Version 3.0.1 of the OpenApi specification.
+    ///
+    /// Refer to the official
+    /// [specification](https://github.com/OAI/OpenAPI-Specification/blob/0dd79f6/versions/3.0.1.md)
+    /// for more information.
+    #[allow(non_camel_case_types)]
+    V3_0(v3_0::Spec),
+}
+
 /// deserialize an open api spec from a path
-pub fn from_path<P>(path: P) -> errors::Result<Spec>
+pub fn from_path<P>(path: P) -> errors::Result<OpenApi>
 where
     P: AsRef<Path>,
 {
@@ -65,31 +99,112 @@ where
 }
 
 /// deserialize an open api spec from type which implements Read
-pub fn from_reader<R>(read: R) -> errors::Result<Spec>
+pub fn from_reader<R>(read: R) -> errors::Result<OpenApi>
 where
     R: Read,
 {
-    Ok(serde_yaml::from_reader::<R, Spec>(read)?)
+    Ok(serde_yaml::from_reader::<R, OpenApi>(read)?)
 }
 
 /// serialize to a yaml string
-pub fn to_yaml(spec: &Spec) -> errors::Result<String> {
+pub fn to_yaml(spec: &OpenApi) -> errors::Result<String> {
     Ok(serde_yaml::to_string(spec)?)
 }
 
 /// serialize to a json string
-pub fn to_json(spec: &Spec) -> errors::Result<String> {
+pub fn to_json(spec: &OpenApi) -> errors::Result<String> {
     Ok(serde_json::to_string_pretty(spec)?)
 }
 
 #[cfg(test)]
 mod tests {
     use super::*;
+    use std::fs::File;
+    use std::io::Write;
+
+    /// Helper function for reading a file to string.
+    fn read_file<P>(path: P) -> String
+    where
+        P: AsRef<Path>,
+    {
+        let mut f = File::open(path).unwrap();
+        let mut content = String::new();
+        f.read_to_string(&mut content).unwrap();
+        content
+    }
+
+    /// Helper function to write string to file.
+    fn write_to_file<P>(path: P, filename: &str, data: &str)
+    where
+        P: AsRef<Path> + std::fmt::Debug,
+    {
+        println!("    Saving string to {:?}...", path);
+        std::fs::create_dir_all(&path).unwrap();
+        let full_filename = path.as_ref().to_path_buf().join(filename);
+        let mut f = File::create(&full_filename).unwrap();
+        f.write_all(data.as_bytes()).unwrap();
+    }
+
+    /// Convert a YAML `&str` to a JSON `String`.
+    fn convert_yaml_str_to_json(yaml_str: &str) -> String {
+        let yaml: serde_yaml::Value = serde_yaml::from_str(yaml_str).unwrap();
+        let json: serde_json::Value = serde_yaml::from_value(yaml).unwrap();
+        serde_json::to_string_pretty(&json).unwrap()
+    }
+
+    /// Deserialize and re-serialize the input file to a JSON string through two different
+    /// paths, comparing the result.
+    /// 1. File -> `String` -> `serde_yaml::Value` -> `serde_json::Value` -> `String`
+    /// 2. File -> `Spec` -> `serde_json::Value` -> `String`
+    /// Both conversion of `serde_json::Value` -> `String` are done
+    /// using `serde_json::to_string_pretty`.
+    /// Since the first conversion is independant of the current crate (and only
+    /// uses serde's json and yaml support), no information should be lost in the final
+    /// JSON string. The second conversion goes through our `OpenApi`, so the final JSON
+    /// string is a representation of _our_ implementation.
+    /// By comparing those two JSON conversions, we can validate our implementation.
+    fn compare_spec_through_json(input_file: &Path, save_path_base: &Path) -> (String, String, String) {
+        // First conversion:
+        //     File -> `String` -> `serde_yaml::Value` -> `serde_json::Value` -> `String`
+
+        // Read the original file to string
+        let spec_yaml_str = read_file(&input_file);
+        // Convert YAML string to JSON string
+        let spec_json_str = convert_yaml_str_to_json(&spec_yaml_str);
+
+        // Second conversion:
+        //     File -> `Spec` -> `serde_json::Value` -> `String`
+
+        // Parse the input file
+        let parsed_spec = from_path(&input_file).unwrap();
+        // Convert to serde_json::Value
+        let parsed_spec_json: serde_json::Value = serde_json::to_value(parsed_spec).unwrap();
+        // Convert to a JSON string
+        let parsed_spec_json_str: String = serde_json::to_string_pretty(&parsed_spec_json).unwrap();
+
+        // Save JSON strings to file
+        let api_filename = input_file.file_name()
+            .unwrap()
+            .to_str()
+            .unwrap()
+            .replace(".yaml", ".json");
+
+        let mut save_path = save_path_base.to_path_buf();
+        save_path.push("yaml_to_json");
+        write_to_file(&save_path, &api_filename, &spec_json_str);
+
+        let mut save_path = save_path_base.to_path_buf();
+        save_path.push("yaml_to_spec_to_json");
+        write_to_file(&save_path, &api_filename, &parsed_spec_json_str);
+
+        // Return the JSON filename and the two JSON strings
+        (api_filename, parsed_spec_json_str, spec_json_str)
+    }
 
     // Just tests if the deserialization does not blow up. But does not test correctness
     #[test]
     fn can_deserialize() {
-        for entry in fs::read_dir("data/").unwrap() {
+        for entry in fs::read_dir("data/v2").unwrap() {
             let entry = entry.unwrap();
             let path = entry.path();
             // cargo test -- --nocapture to see this message
@@ -97,4 +212,64 @@ mod tests {
             from_path(path).unwrap();
         }
     }
+
+    #[test]
+    fn can_deserialize_and_reserialize_v2() {
+        let save_path_base: std::path::PathBuf = [
+            "target",
+            "tests",
+            "can_deserialize_and_reserialize_v2",
+        ].iter()
+            .collect();
+        let mut invalid_diffs = Vec::new();
+
+        for entry in fs::read_dir("data/v2").unwrap() {
+            let entry = entry.unwrap();
+            let path = entry.path();
+
+            println!("Testing if {:?} is deserializable", path);
+
+            let (api_filename, parsed_spec_json_str, spec_json_str) =
+                compare_spec_through_json(&path, &save_path_base);
+
+            if parsed_spec_json_str != spec_json_str {
+                invalid_diffs.push((api_filename, parsed_spec_json_str, spec_json_str));
+            }
+        }
+
+        for invalid_diff in &invalid_diffs {
+            println!("File {} failed JSON comparison!", invalid_diff.0);
+        }
+        assert!(invalid_diffs.len() == 0);
+    }
+
+    #[test]
+    fn can_deserialize_and_reserialize_v3() {
+        let save_path_base: std::path::PathBuf = [
+            "target",
+            "tests",
+            "can_deserialize_and_reserialize_v3",
+        ].iter()
+            .collect();
+        let mut invalid_diffs = Vec::new();
+
+        for entry in fs::read_dir("data/v3.0").unwrap() {
+            let entry = entry.unwrap();
+            let path = entry.path();
+
+            println!("Testing if {:?} is deserializable", path);
+
+            let (api_filename, parsed_spec_json_str, spec_json_str) =
+                compare_spec_through_json(&path, &save_path_base);
+
+            if parsed_spec_json_str != spec_json_str {
+                invalid_diffs.push((api_filename, parsed_spec_json_str, spec_json_str));
+            }
+        }
+
+        for invalid_diff in &invalid_diffs {
+            println!("File {} failed JSON comparison!", invalid_diff.0);
+        }
+        assert!(invalid_diffs.len() == 0);
+    }
 }
diff --git a/src/v2/mod.rs b/src/v2/mod.rs
new file mode 100644
index 0000000..7da08c5
--- /dev/null
+++ b/src/v2/mod.rs
@@ -0,0 +1,9 @@
+//! Support for OpenApi version 2.0 specification.
+//!
+//! See the
+//! [specification](https://github.com/OAI/OpenAPI-Specification/blob/0dd79f6/versions/2.0.md)
+//! for more information.
+
+mod schema;
+
+pub use v2::schema::*;
diff --git a/src/schema.rs b/src/v2/schema.rs
similarity index 99%
rename from src/schema.rs
rename to src/v2/schema.rs
index 17e1c65..d03aa12 100644
--- a/src/schema.rs
+++ b/src/v2/schema.rs
@@ -44,7 +44,7 @@ pub struct Spec {
     pub tags: Option<Vec<Tag>>,
     /// Relative paths to the individual endpoints. They must be relative
     /// to the 'basePath'.
-    pub paths: BTreeMap<String, Operations>,
+    pub paths: BTreeMap<String, PathItem>,
     #[serde(skip_serializing_if = "Option::is_none")]
     pub definitions: Option<BTreeMap<String, Schema>>,
     #[serde(skip_serializing_if = "Option::is_none")]
diff --git a/src/v3_0/components.rs b/src/v3_0/components.rs
new file mode 100644
index 0000000..535b0db
--- /dev/null
+++ b/src/v3_0/components.rs
@@ -0,0 +1,58 @@
+use std::collections::BTreeMap;
+
+use v3_0::{Callback, Example, Header, Link, Parameter, RequestBody, Response, Schema,
+           SecurityScheme};
+
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+#[serde(untagged)]
+pub enum ObjectOrReference<T> {
+    Object(T),
+    Ref {
+        #[serde(rename = "$ref")] ref_path: String,
+    },
+}
+
+/// Holds a set of reusable objects for different aspects of the OAS.
+/// All objects defined within the components object will have no effect on the API unless
+/// they are explicitly referenced from properties outside the components object.
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#componentsObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct Components {
+    /// An object to hold reusable Schema Objects.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub schemas: Option<BTreeMap<String, ObjectOrReference<Schema>>>,
+
+    /// An object to hold reusable Response Objects.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub responses: Option<BTreeMap<String, ObjectOrReference<Response>>>,
+
+    /// An object to hold reusable Parameter Objects.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub parameters: Option<BTreeMap<String, ObjectOrReference<Parameter>>>,
+
+    /// An object to hold reusable Example
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub examples: Option<BTreeMap<String, ObjectOrReference<Example>>>,
+
+    /// An object to hold reusable Request Body Objects.
+    #[serde(skip_serializing_if = "Option::is_none", rename = "requestBodies")]
+    pub request_bodies: Option<BTreeMap<String, ObjectOrReference<RequestBody>>>,
+
+    /// An object to hold reusable Header Objects.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub headers: Option<BTreeMap<String, ObjectOrReference<Header>>>,
+
+    /// An object to hold reusable Security Scheme Objects.
+    #[serde(skip_serializing_if = "Option::is_none", rename = "securitySchemes")]
+    pub security_schemes: Option<BTreeMap<String, ObjectOrReference<SecurityScheme>>>,
+
+    /// An object to hold reusable Link Objects.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub links: Option<BTreeMap<String, ObjectOrReference<Link>>>,
+
+    /// An object to hold reusable Callback Objects.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub callbacks: Option<BTreeMap<String, ObjectOrReference<Callback>>>,
+    // TODO: Add "Specification Extensions" https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtensions}
+}
diff --git a/src/v3_0/mod.rs b/src/v3_0/mod.rs
new file mode 100644
index 0000000..30df2c9
--- /dev/null
+++ b/src/v3_0/mod.rs
@@ -0,0 +1,11 @@
+//! Support for OpenApi version 3.0.1 specification.
+//!
+//! See the
+//! [specification](https://github.com/OAI/OpenAPI-Specification/blob/0dd79f6/versions/3.0.1.md)
+//! for more information.
+
+mod schema;
+mod components;
+
+pub use v3_0::schema::*;
+pub use v3_0::components::*;
diff --git a/src/v3_0/schema.rs b/src/v3_0/schema.rs
new file mode 100644
index 0000000..fc87647
--- /dev/null
+++ b/src/v3_0/schema.rs
@@ -0,0 +1,854 @@
+use std::collections::BTreeMap;
+
+use url;
+use url_serde;
+use semver;
+use serde_json;
+
+use MINIMUM_OPENAPI30_VERSION;
+use v3_0::components::{Components, ObjectOrReference};
+use errors;
+
+impl Spec {
+    pub fn validate_version(&self) -> errors::Result<semver::Version> {
+        let spec_version = &self.openapi;
+        let sem_ver = semver::Version::parse(spec_version)?;
+        let required_version = semver::VersionReq::parse(MINIMUM_OPENAPI30_VERSION).unwrap();
+        if required_version.matches(&sem_ver) {
+            Ok(sem_ver)
+        } else {
+            Err(errors::ErrorKind::UnsupportedSpecFileVersion(sem_ver))?
+        }
+    }
+}
+
+/// top level document
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct Spec {
+    /// This string MUST be the [semantic version number](https://semver.org/spec/v2.0.0.html)
+    /// of the
+    /// [OpenAPI Specification version](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#versions)
+    /// that the OpenAPI document uses. The `openapi` field SHOULD be used by tooling
+    /// specifications and clients to interpret the OpenAPI document. This is not related to
+    /// the API
+    /// [`info.version`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#infoVersion)
+    /// string.
+    pub openapi: String,
+    /// Provides metadata about the API. The metadata MAY be used by tooling as required.
+    pub info: Info,
+    /// An array of Server Objects, which provide connectivity information to a target server.
+    /// If the `servers` property is not provided, or is an empty array, the default value would
+    /// be a
+    /// [Server Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#serverObject)
+    /// with a
+    /// [url](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#serverUrl)
+    /// value of `/`.
+    // FIXME: Provide a default value as specified in documentation instead of `None`.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub servers: Option<Vec<Server>>,
+
+    /// Holds the relative paths to the individual endpoints and their operations. The path is
+    /// appended to the URL from the
+    /// [`Server Object`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#serverObject)
+    /// in order to construct the full URL. The Paths MAY be empty, due to
+    /// [ACL constraints](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#securityFiltering).
+    pub paths: BTreeMap<String, PathItem>,
+
+    /// An element to hold various schemas for the specification.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub components: Option<Components>,
+
+    // FIXME: Implement
+    // /// A declaration of which security mechanisms can be used across the API.
+    // /// The list of  values includes alternative security requirement objects that can be used.
+    // /// Only one of the security requirement objects need to be satisfied to authorize a request.
+    // /// Individual operations can override this definition.
+    // #[serde(skip_serializing_if = "Option::is_none")]
+    // pub security: Option<SecurityRequirement>,
+    /// A list of tags used by the specification with additional metadata.
+    ///The order of the tags can be used to reflect on their order by the parsing tools.
+    /// Not all tags that are used by the
+    /// [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#operationObject)
+    /// must be declared. The tags that are not declared MAY be organized randomly or
+    /// based on the tools' logic. Each tag name in the list MUST be unique.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub tags: Option<Vec<Tag>>,
+
+    /// Additional external documentation.
+    #[serde(skip_serializing_if = "Option::is_none", rename = "externalDocs")]
+    pub external_docs: Option<ExternalDoc>,
+    // TODO: Add "Specification Extensions" https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtensions}
+}
+
+/// General information about the API.
+///
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#infoObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+// #[serde(rename_all = "lowercase")]
+pub struct Info {
+    /// The title of the application.
+    pub title: String,
+    /// A short description of the application. CommonMark syntax MAY be used for rich text representation.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub description: Option<String>,
+    /// A URL to the Terms of Service for the API. MUST be in the format of a URL.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub terms_of_service: Option<String>,
+    /// REQUIRED. The version of the OpenAPI document (which is distinct from the [OpenAPI Specification version](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#oasVersion)
+    /// or the API implementation version).
+    pub version: String,
+    /// The contact information for the exposed API.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub contact: Option<Contact>,
+    /// The license information for the exposed API.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub license: Option<License>,
+}
+
+/// Wraper around `url::Url` to fix serde issue
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+pub struct Url(#[serde(with = "url_serde")] url::Url);
+
+/// Contact information for the exposed API.
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#contactObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct Contact {
+    #[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>,
+
+    #[serde(skip_serializing_if = "Option::is_none")] pub url: Option<Url>,
+
+    // TODO: Make sure the email is a valid email
+    #[serde(skip_serializing_if = "Option::is_none")] pub email: Option<String>,
+    // TODO: Add "Specification Extensions" https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtensions
+}
+
+/// License information for the exposed API.
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#licenseObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct License {
+    /// The license name used for the API.
+    pub name: String,
+    /// A URL to the license used for the API.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub url: Option<Url>,
+    // TODO: Add "Specification Extensions" https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtensions}
+}
+
+/// An object representing a Server.
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#serverObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct Server {
+    /// A URL to the target host. This URL supports Server Variables and MAY be relative, to
+    /// indicate that the host location is relative to the location where the OpenAPI document
+    /// is being served. Variable substitutions will be made when a variable is named
+    /// in {brackets}.
+    pub url: String,
+    /// An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text representation.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub description: Option<String>,
+    // // FIXME: Add this. See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#server-object
+    // /// A map between a variable name and its value. The value is used for substitution in
+    // /// the server's URL template.
+    // pub variables: ,
+}
+
+/// Describes the operations available on a single path.
+/// A Path Item MAY be empty, due to
+/// [ACL constraints](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#securityFiltering).
+/// The path itself is still exposed to the documentation viewer but they will
+/// not know which operations and parameters are available.
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct PathItem {
+    /// Allows for an external definition of this path item. The referenced structure MUST be
+    /// in the format of a
+    /// [Path Item Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#pathItemObject).
+    /// If there are conflicts between the referenced definition and this Path Item's definition,
+    /// the behavior is undefined.
+    // FIXME: Should this ref be moved to an enum?
+    #[serde(skip_serializing_if = "Option::is_none", rename = "$ref")]
+    pub reference: Option<String>,
+
+    /// An optional, string summary, intended to apply to all operations in this path.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub summary: Option<String>,
+    /// An optional, string description, intended to apply to all operations in this path.
+    /// [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub description: Option<String>,
+
+    /// A definition of a GET operation on this path.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub get: Option<Operation>,
+    /// A definition of a PUT operation on this path.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub put: Option<Operation>,
+    /// A definition of a POST operation on this path.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub post: Option<Operation>,
+    /// A definition of a DELETE operation on this path.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub delete: Option<Operation>,
+    /// A definition of a OPTIONS operation on this path.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub options: Option<Operation>,
+    /// A definition of a HEAD operation on this path.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub head: Option<Operation>,
+    /// A definition of a PATCH operation on this path.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub patch: Option<Operation>,
+    /// A definition of a TRACE operation on this path.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub trace: Option<Operation>,
+
+    /// An alternative `server` array to service all operations in this path.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub servers: Option<Vec<Server>>,
+
+    /// A list of parameters that are applicable for all the operations described under this
+    /// path. These parameters can be overridden at the operation level, but cannot be removed
+    /// there. The list MUST NOT include duplicated parameters. A unique parameter is defined by
+    /// a combination of a
+    /// [name](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterName)
+    /// and
+    /// [location](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterIn).
+    /// The list can use the
+    /// [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#referenceObject)
+    /// to link to parameters that are defined at the
+    /// [OpenAPI Object's components/parameters](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#componentsParameters).
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub parameters: Option<Vec<ObjectOrReference<Parameter>>>,
+    // TODO: Add "Specification Extensions" https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtensions}
+}
+
+/// Describes a single API operation on a path.
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#operationObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+// #[serde(rename_all = "lowercase")]
+pub struct Operation {
+    /// A list of tags for API documentation control. Tags can be used for logical grouping of
+    /// operations by resources or any other qualifier.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub tags: Option<Vec<String>>,
+    /// A short summary of what the operation does.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub summary: Option<String>,
+    /// A verbose explanation of the operation behavior.
+    /// [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub description: Option<String>,
+    /// Additional external documentation for this operation.
+    #[serde(skip_serializing_if = "Option::is_none", rename = "externalDocs")]
+    pub external_docs: Option<ExternalDoc>,
+    /// Unique string used to identify the operation. The id MUST be unique among all operations
+    /// described in the API. Tools and libraries MAY use the operationId to uniquely identify an
+    /// operation, therefore, it is RECOMMENDED to follow common programming naming conventions.
+    #[serde(skip_serializing_if = "Option::is_none", rename = "operationId")]
+    pub operation_id: Option<String>,
+
+    /// A list of parameters that are applicable for this operation. If a parameter is already
+    /// defined at the
+    /// [Path Item](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#pathItemParameters),
+    /// the new definition will override it but can never remove it. The list MUST NOT
+    /// include duplicated parameters. A unique parameter is defined by a combination of a
+    /// [name](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterName)
+    /// and
+    /// [location](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterIn).
+    /// The list can use the
+    /// [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#referenceObject)
+    /// to link to parameters that are defined at the
+    /// [OpenAPI Object's components/parameters](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#componentsParameters).
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub parameters: Option<Vec<ObjectOrReference<Parameter>>>,
+
+    /// The request body applicable for this operation. The requestBody is only supported in HTTP methods where the HTTP 1.1 specification RFC7231 has explicitly defined semantics for request bodies. In other cases where the HTTP spec is vague, requestBody SHALL be ignored by consumers.
+    #[serde(skip_serializing_if = "Option::is_none", rename = "requestBody")]
+    pub request_body: Option<ObjectOrReference<RequestBody>>,
+
+    /// The list of possible responses as they are returned from executing this operation.
+    ///
+    /// A container for the expected responses of an operation. The container maps a HTTP
+    /// response code to the expected response.
+    ///
+    /// The documentation is not necessarily expected to cover all possible HTTP response codes
+    /// because they may not be known in advance. However, documentation is expected to cover
+    /// a successful operation response and any known errors.
+    ///
+    /// The `default` MAY be used as a default response object for all HTTP codes that are not
+    /// covered individually by the specification.
+    ///
+    /// The `Responses Object` MUST contain at least one response code, and it SHOULD be the
+    /// response for a successful operation call.
+    ///
+    /// See [link]
+    /// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#responsesObject]
+    pub responses: BTreeMap<String, Response>,
+
+    // FIXME: Implement
+    /// A map of possible out-of band callbacks related to the parent operation. The key is
+    /// a unique identifier for the Callback Object. Each value in the map is a
+    /// [Callback Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#callbackObject)
+    /// that describes a request that may be initiated by the API provider and the
+    /// expected responses. The key value used to identify the callback object is
+    /// an expression, evaluated at runtime, that identifies a URL to use for the
+    /// callback operation.
+    // pub callbacks: Option<???>,
+
+    /// Declares this operation to be deprecated. Consumers SHOULD refrain from usage
+    /// of the declared operation. Default value is `false`.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub deprecated: Option<bool>,
+
+    // FIXME: Implement
+    // /// A declaration of which security mechanisms can be used for this operation. The list of
+    // /// values includes alternative security requirement objects that can be used. Only one
+    // /// of the security requirement objects need to be satisfied to authorize a request.
+    // /// This definition overrides any declared top-level
+    // /// [`security`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#oasSecurity).
+    // /// To remove a top-level security declaration, an empty array can be used.
+    // pub security: Option<SecurityRequirement>,
+    /// An alternative `server` array to service this operation. If an alternative `server`
+    /// object is specified at the Path Item Object or Root level, it will be overridden by
+    /// this value.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub servers: Option<Vec<Server>>,
+}
+
+// FIXME: Verify against OpenAPI 3.0
+/// Describes a single operation parameter.
+/// A unique parameter is defined by a combination of a
+/// [name](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterName)
+/// and [location](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterIn).
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct Parameter {
+    /// The name of the parameter.
+    name: String,
+    /// values depend on parameter type
+    /// may be `header`, `query`, 'path`, `formData`
+    #[serde(rename = "in")]
+    location: String,
+    #[serde(skip_serializing_if = "Option::is_none")] required: Option<bool>,
+    #[serde(skip_serializing_if = "Option::is_none")] schema: Option<Schema>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    #[serde(rename = "uniqueItems")]
+    unique_items: Option<bool>,
+    /// string, number, boolean, integer, array, file ( only for formData )
+    #[serde(skip_serializing_if = "Option::is_none")]
+    #[serde(rename = "type")]
+    param_type: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")] format: Option<String>,
+    /// A brief description of the parameter. This could contain examples
+    /// of use.  GitHub Flavored Markdown is allowed.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    description: Option<String>,
+    // collectionFormat: ???
+    // default: ???
+    // maximum ?
+    // exclusiveMaximum ??
+    // minimum ??
+    // exclusiveMinimum ??
+    // maxLength ??
+    // minLength ??
+    // pattern ??
+    // maxItems ??
+    // minItems ??
+    // enum ??
+    // multipleOf ??
+    // allowEmptyValue ( for query / body params )
+}
+
+// FIXME: Verify against OpenAPI 3.0
+/// The Schema Object allows the definition of input and output data types.
+/// These types can be objects, but also primitives and arrays.
+/// This object is an extended subset of the
+/// [JSON Schema Specification Wright Draft 00](http://json-schema.org/).
+/// For more information about the properties, see
+/// [JSON Schema Core](https://tools.ietf.org/html/draft-wright-json-schema-00) and
+/// [JSON Schema Validation](https://tools.ietf.org/html/draft-wright-json-schema-validation-00).
+/// Unless stated otherwise, the property definitions follow the JSON Schema.
+///
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#schemaObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct Schema {
+    /// [JSON reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03)
+    /// path to another defintion
+    #[serde(skip_serializing_if = "Option::is_none")]
+    #[serde(rename = "$ref")]
+    pub ref_path: Option<String>,
+
+    #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>,
+
+    #[serde(skip_serializing_if = "Option::is_none")]
+    #[serde(rename = "type")]
+    pub schema_type: Option<String>,
+
+    #[serde(skip_serializing_if = "Option::is_none")] pub format: Option<String>,
+
+    #[serde(skip_serializing_if = "Option::is_none")]
+    #[serde(rename = "enum")]
+    pub enum_values: Option<Vec<String>>,
+
+    #[serde(skip_serializing_if = "Option::is_none")] pub required: Option<Vec<String>>,
+
+    #[serde(skip_serializing_if = "Option::is_none")] pub items: Option<Box<Schema>>,
+
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub properties: Option<BTreeMap<String, Schema>>,
+
+    #[serde(skip_serializing_if = "Option::is_none", rename = "readOnly")]
+    pub read_only: Option<bool>,
+
+    /// Value can be boolean or object. Inline or referenced schema MUST be of a
+    /// [Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#schemaObject)
+    /// and not a standard JSON Schema.
+    /// See [link]
+    /// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#properties]
+    // FIXME: Why can this be a "boolean" (as per the spec)? It doesn't make sense. Here it's not.
+    #[serde(skip_serializing_if = "Option::is_none", rename = "additionalProperties")]
+    pub additional_properties: Option<ObjectOrReference<Box<Schema>>>,
+
+    /// A free-form property to include an example of an instance for this schema.
+    /// To represent examples that cannot be naturally represented in JSON or YAML,
+    /// a string value can be used to contain the example with escaping where necessary.
+    /// NOTE: According to [spec], _Primitive data types in the OAS are based on the
+    ///       types supported by the JSON Schema Specification Wright Draft 00._
+    ///       This suggest using
+    ///       [`serde_json::Value`](https://docs.serde.rs/serde_json/value/enum.Value.html). [spec][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#data-types]
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub example: Option<serde_json::value::Value>,
+    // The following properties are taken directly from the JSON Schema definition and
+    // follow the same specifications:
+    // title
+    // multipleOf
+    // maximum
+    // exclusiveMaximum
+    // minimum
+    // exclusiveMinimum
+    // maxLength
+    // minLength
+    // pattern (This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect)
+    // maxItems
+    // minItems
+    // uniqueItems
+    // maxProperties
+    // minProperties
+    // required
+    // enum
+
+    // The following properties are taken from the JSON Schema definition but their
+    // definitions were adjusted to the OpenAPI Specification.
+    // - type - Value MUST be a string. Multiple types via an array are not supported.
+    // - allOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema.
+    // - oneOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema.
+    // - anyOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema.
+    // - not - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema.
+    // - items - Value MUST be an object and not an array. Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. `items` MUST be present if the `type` is `array`.
+    // - properties - Property definitions MUST be a [Schema Object](#schemaObject) and not a standard JSON Schema (inline or referenced).
+    // - additionalProperties - Value can be boolean or object. Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema.
+    // - description - [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.
+    // - format - See [Data Type Formats](#dataTypeFormat) for further details. While relying on JSON Schema's defined formats, the OAS offers a few additional predefined formats.
+    // - default - The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided. Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. For example, if `type` is `string`, then `default` can be `"foo"` but cannot be `1`.
+}
+
+/// Describes a single response from an API Operation, including design-time, static `links`
+/// to operations based on the response.
+///
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#responseObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct Response {
+    /// A short description of the response.
+    /// [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.
+    pub description: Option<String>,
+
+    /// Maps a header name to its definition.
+    /// [RFC7230](https://tools.ietf.org/html/rfc7230#page-22) states header names are case
+    /// insensitive. If a response header is defined with the name `"Content-Type"`, it SHALL
+    /// be ignored.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub headers: Option<BTreeMap<String, ObjectOrReference<Header>>>,
+
+    /// A map containing descriptions of potential response payloads. The key is a media type
+    /// or [media type range](https://tools.ietf.org/html/rfc7231#appendix-D) and the value
+    /// describes it. For responses that match multiple keys, only the most specific key is
+    /// applicable. e.g. text/plain overrides text/*
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub content: Option<BTreeMap<String, MediaType>>,
+
+    /// A map of operations links that can be followed from the response. The key of the map
+    /// is a short name for the link, following the naming constraints of the names for
+    /// [Component Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#componentsObject).
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub links: Option<BTreeMap<String, ObjectOrReference<Link>>>,
+    // TODO: Add "Specification Extensions" https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtensions}
+}
+
+/// The Header Object follows the structure of the
+/// [Parameter Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterObject)
+/// with the following changes:
+/// 1. `name` MUST NOT be specified, it is given in the corresponding `headers` map.
+/// 1. `in` MUST NOT be specified, it is implicitly in `header`.
+/// 1. All traits that are affected by the location MUST be applicable to a location of
+///    `header` (for example, [`style`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterStyle)).
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#headerObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct Header {
+    // FIXME: Is the third change properly implemented?
+    // FIXME: Merge `ObjectOrReference<Header>::Reference` and `ParameterOrRef::Reference`
+    #[serde(skip_serializing_if = "Option::is_none")] required: Option<bool>,
+    #[serde(skip_serializing_if = "Option::is_none")] schema: Option<Schema>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    #[serde(rename = "uniqueItems")]
+    unique_items: Option<bool>,
+    /// string, number, boolean, integer, array, file ( only for formData )
+    #[serde(skip_serializing_if = "Option::is_none")]
+    #[serde(rename = "type")]
+    param_type: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")] format: Option<String>,
+    /// A brief description of the parameter. This could contain examples
+    /// of use.  GitHub Flavored Markdown is allowed.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    description: Option<String>,
+    // collectionFormat: ???
+    // default: ???
+    // maximum ?
+    // exclusiveMaximum ??
+    // minimum ??
+    // exclusiveMinimum ??
+    // maxLength ??
+    // minLength ??
+    // pattern ??
+    // maxItems ??
+    // minItems ??
+    // enum ??
+    // multipleOf ??
+    // allowEmptyValue ( for query / body params )
+}
+
+/// Describes a single request body.
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#requestBodyObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct RequestBody {
+    /// A brief description of the request body. This could contain examples of use.
+    /// [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub description: Option<String>,
+
+    /// The content of the request body. The key is a media type or
+    /// [media type range](https://tools.ietf.org/html/rfc7231#appendix-D) and the
+    /// value describes it. For requests that match multiple keys, only the most specific key
+    /// is applicable. e.g. text/plain overrides text/*
+    pub content: BTreeMap<String, MediaType>,
+
+    #[serde(skip_serializing_if = "Option::is_none")] pub required: Option<bool>,
+}
+
+/// The Link object represents a possible design-time link for a response.
+///
+/// The presence of a link does not guarantee the caller's ability to successfully invoke it,
+/// rather it provides a known relationship and traversal mechanism between responses and
+/// other operations.
+///
+/// Unlike _dynamic_ links (i.e. links provided *in* the response payload), the OAS linking
+/// mechanism does not require link information in the runtime response.
+///
+/// For computing links, and providing instructions to execute them, a
+/// [runtime expression](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#runtimeExpression)
+/// is used for accessing values in an operation and using them as parameters while invoking
+/// the linked operation.
+///
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#linkObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+#[serde(untagged)]
+pub enum Link {
+    /// A relative or absolute reference to an OAS operation. This field is mutually exclusive
+    /// of the `operationId` field, and MUST point to an
+    /// [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#operationObject).
+    /// Relative `operationRef` values MAY be used to locate an existing
+    /// [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#operationObject)
+    /// in the OpenAPI definition.
+    Ref {
+        #[serde(rename = "operationRef")] operation_ref: String,
+
+        // FIXME: Implement
+        // /// A map representing parameters to pass to an operation as specified with `operationId`
+        // /// or identified via `operationRef`. The key is the parameter name to be used, whereas
+        // /// the value can be a constant or an expression to be evaluated and passed to the
+        // /// linked operation. The parameter name can be qualified using the
+        // /// [parameter location](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterIn)
+        // /// `[{in}.]{name}` for operations that use the same parameter name in different
+        // /// locations (e.g. path.id).
+        // parameters: BTreeMap<String, Any | {expression}>,
+
+        // FIXME: Implement
+        // /// A literal value or
+        // /// [{expression}](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#runtimeExpression)
+        // /// to use as a request body when calling the target operation.
+        // #[serde(rename = "requestBody")]
+        // request_body: Any | {expression}
+        /// A description of the link. [CommonMark syntax](http://spec.commonmark.org/) MAY be
+        /// used for rich text representation.
+        #[serde(skip_serializing_if = "Option::is_none")]
+        description: Option<String>,
+
+        /// A server object to be used by the target operation.
+        #[serde(skip_serializing_if = "Option::is_none")]
+        server: Option<Server>,
+        // TODO: Add "Specification Extensions" https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtension
+    },
+    /// The name of an _existing_, resolvable OAS operation, as defined with a unique
+    /// `operationId`. This field is mutually exclusive of the `operationRef` field.
+    Id {
+        #[serde(rename = "operationId")] operation_id: String,
+
+        // FIXME: Implement
+        // /// A map representing parameters to pass to an operation as specified with `operationId`
+        // /// or identified via `operationRef`. The key is the parameter name to be used, whereas
+        // /// the value can be a constant or an expression to be evaluated and passed to the
+        // /// linked operation. The parameter name can be qualified using the
+        // /// [parameter location](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterIn)
+        // /// `[{in}.]{name}` for operations that use the same parameter name in different
+        // /// locations (e.g. path.id).
+        // parameters: BTreeMap<String, Any | {expression}>,
+
+        // FIXME: Implement
+        // /// A literal value or
+        // /// [{expression}](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#runtimeExpression)
+        // /// to use as a request body when calling the target operation.
+        // #[serde(rename = "requestBody")]
+        // request_body: Any | {expression}
+        /// A description of the link. [CommonMark syntax](http://spec.commonmark.org/) MAY be
+        /// used for rich text representation.
+        #[serde(skip_serializing_if = "Option::is_none")]
+        description: Option<String>,
+
+        /// A server object to be used by the target operation.
+        #[serde(skip_serializing_if = "Option::is_none")]
+        server: Option<Server>,
+        // TODO: Add "Specification Extensions" https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtension
+    },
+}
+
+/// Each Media Type Object provides schema and examples for the media type identified by its key.
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#media-type-object]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct MediaType {
+    /// The schema defining the type used for the request body.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub schema: Option<ObjectOrReference<Schema>>,
+
+    /// Example of the media type.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub examples: Option<MediaTypeExample>,
+
+    /// A map between a property name and its encoding information. The key, being the
+    /// property name, MUST exist in the schema as a property. The encoding object SHALL
+    /// only apply to `requestBody` objects when the media type is `multipart`
+    /// or `application/x-www-form-urlencoded`.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub encoding: Option<BTreeMap<String, Encoding>>,
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+#[serde(untagged)]
+pub enum MediaTypeExample {
+    /// Example of the media type. The example object SHOULD be in the correct format as
+    /// specified by the media type. The `example` field is mutually exclusive of the
+    /// `examples` field. Furthermore, if referencing a `schema` which contains an example,
+    /// the `example` value SHALL override the example provided by the schema.
+    Example { example: String },
+    /// Examples of the media type. Each example object SHOULD match the media type and
+    /// specified schema if present. The `examples` field is mutually exclusive of
+    /// the `example` field. Furthermore, if referencing a `schema` which contains an
+    /// example, the `examples` value SHALL override the example provided by the schema.
+    Examples {
+        examples: Option<BTreeMap<String, ObjectOrReference<Example>>>,
+    },
+}
+
+/// A single encoding definition applied to a single schema property.
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct Encoding {
+    /// The Content-Type for encoding a specific property. Default value depends on the
+    /// property type: for `string` with `format` being `binary` – `application/octet-stream`;
+    /// for other primitive types – `text/plain`; for `object` - `application/json`;
+    /// for `array` – the default is defined based on the inner type. The value can be a
+    /// specific media type (e.g. `application/json`), a wildcard media type
+    /// (e.g. `image/*`), or a comma-separated list of the two types.
+    #[serde(skip_serializing_if = "Option::is_none", rename = "contentType")]
+    pub content_type: Option<String>,
+
+    /// A map allowing additional information to be provided as headers, for example
+    /// `Content-Disposition`.  `Content-Type` is described separately and SHALL be
+    /// ignored in this section. This property SHALL be ignored if the request body
+    /// media type is not a `multipart`.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub headers: Option<BTreeMap<String, ObjectOrReference<Header>>>,
+
+    /// Describes how a specific property value will be serialized depending on its type.
+    /// See [Parameter Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterObject)
+    /// for details on the
+    /// [`style`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#parameterStyle)
+    /// property. The behavior follows the same values as `query` parameters, including
+    /// default values. This property SHALL be ignored if the request body media type
+    /// is not `application/x-www-form-urlencoded`.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub style: Option<String>,
+
+    /// When this is true, property values of type `array` or `object` generate
+    /// separate parameters for each value of the array, or key-value-pair of the map.
+    /// For other types of properties this property has no effect. When
+    /// [`style`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#encodingStyle)
+    /// is `form`, the default value is `true`. For all other styles, the default value
+    /// is `false`. This property SHALL be ignored if the request body media type is
+    /// not `application/x-www-form-urlencoded`.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub explode: Option<bool>,
+
+    /// Determines whether the parameter value SHOULD allow reserved characters, as defined
+    /// by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=`
+    /// to be included without percent-encoding. The default value is `false`. This
+    /// property SHALL be ignored if the request body media type is
+    /// not `application/x-www-form-urlencoded`.
+    #[serde(skip_serializing_if = "Option::is_none", rename = "allowReserved")]
+    pub allow_reserved: Option<bool>,
+}
+
+///
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#exampleObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct Example {
+    /// Short description for the example.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub summary: Option<String>,
+
+    /// Long description for the example.
+    /// [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub description: Option<String>,
+    // FIXME: Implement (merge with externalValue as enum)
+    // /// Embedded literal example. The `value` field and `externalValue` field are mutually
+    // /// exclusive. To represent examples of media types that cannot naturally represented
+    // /// in JSON or YAML, use a string value to contain the example, escaping where necessary.
+    // #[serde(skip_serializing_if = "Option::is_none")]
+    // pub value: Option<????>,
+
+    // FIXME: Implement (merge with value as enum)
+    // /// A URL that points to the literal example. This provides the capability to reference
+    // /// examples that cannot easily be included in JSON or YAML documents. The `value` field
+    // /// and `externalValue` field are mutually exclusive.
+    // #[serde(skip_serializing_if = "Option::is_none")]
+    // pub externalValue: Option<String>,
+
+    // TODO: Add "Specification Extensions" https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtensions}
+}
+
+/// Defines a security scheme that can be used by the operations. Supported schemes are
+/// HTTP authentication, an API key (either as a header or as a query parameter),
+///OAuth2's common flows (implicit, password, application and access code) as defined
+/// in [RFC6749](https://tools.ietf.org/html/rfc6749), and
+/// [OpenID Connect Discovery](https://tools.ietf.org/html/draft-ietf-oauth-discovery-06).
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#securitySchemeObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+#[serde(tag = "type")]
+pub enum SecurityScheme {
+    #[serde(rename = "apiKey")]
+    ApiKey {
+        name: String,
+        #[serde(rename = "in")] location: String,
+    },
+    #[serde(rename = "http")]
+    Http {
+        scheme: String,
+        #[serde(rename = "bearerFormat")] bearer_format: String,
+    },
+    // FIXME: Implement
+    // #[serde(rename = "oauth2")]
+    // Oauth2 {
+    //     flow: String,
+    //     #[serde(rename = "authorizationUrl")]
+    //     authorization_url: String,
+    //     #[serde(rename = "tokenUrl")]
+    //     #[serde(skip_serializing_if = "Option::is_none")]
+    //     token_url: Option<String>,
+    //     scopes: BTreeMap<String, String>,
+    // },
+    #[serde(rename = "openIdConnect")]
+    OpenIdConnect {
+        #[serde(rename = "openIdConnectUrl")] open_id_connect_url: String,
+    },
+}
+
+/// A map of possible out-of band callbacks related to the parent operation. Each value in
+/// the map is a Path Item Object that describes a set of requests that may be initiated by
+/// the API provider and the expected responses. The key value used to identify the callback
+/// object is an expression, evaluated at runtime, that identifies a URL to use for the
+/// callback operation.
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#callbackObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct Callback(
+    /// A Path Item Object used to define a callback request and expected responses.
+    String, // TODO: Add "Specification Extensions" https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtensions}
+);
+
+// FIXME: Implement
+// /// Allows configuration of the supported OAuth Flows.
+// /// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#oauthFlowsObject
+// #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+// pub struct OAuthFlows {
+// }
+
+/// Adds metadata to a single tag that is used by the
+/// [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#operationObject).
+/// It is not mandatory to have a Tag Object per tag defined in the Operation Object instances.
+///
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#tagObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct Tag {
+    /// The name of the tag.
+    pub name: String,
+
+    /// A short description for the tag.
+    /// [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub description: Option<String>,
+    // /// Additional external documentation for this tag.
+    // #[serde(skip_serializing_if = "Option::is_none")]
+    // pub external_docs: Option<Vec<ExternalDoc>>,
+
+    // TODO: Add "Specification Extensions" https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtensions}
+}
+
+/// Allows referencing an external resource for extended documentation.
+/// See [link]
+/// [link][https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#externalDocumentationObject]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
+pub struct ExternalDoc {
+    /// The URL for the target documentation. Value MUST be in the format of a URL.
+    // FIXME: Use `url::Url` instead of `String`
+    // #[serde(with = "url_serde")]
+    // pub url: url::Url,
+    pub url: String,
+
+    /// A short description of the target documentation.
+    /// [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub description: Option<String>,
+    // TODO: Add "Specification Extensions" https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#specificationExtensions}
+}


Test patch: