Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support inherit and expend types #72

Closed
sergey-tihon opened this issue Apr 13, 2017 · 2 comments
Closed

Support inherit and expend types #72

sergey-tihon opened this issue Apr 13, 2017 · 2 comments
Assignees

Comments

@sergey-tihon
Copy link
Member

sergey-tihon commented Apr 13, 2017

Schema

https://api.apis.guru/v2/specs/azure.com/arm-storage/2016-12-01/swagger.json

Sample

"StorageAccount": {
      "allOf": [
        {
          "$ref": "#/definitions/Resource"
        }
      ],
      "description": "The storage account.",
      "properties": {
        "kind": {
          "description": "Gets the Kind.",
          "enum": [
            "Storage",
            "BlobStorage"
          ],
          "readOnly": true,
          "type": "string",
          "x-ms-enum": {
            "modelAsString": false,
            "name": "Kind"
          }
        },
        "properties": {
          "$ref": "#/definitions/StorageAccountProperties",
          "x-ms-client-flatten": true
        },
        "sku": {
          "$ref": "#/definitions/Sku",
          "description": "Gets the SKU.",
          "readOnly": true
        }
      }
    },

StorageAccount should have all properties of Resource type // cc @stuartjdavies

Spec

Composition and Inheritance (Polymorphism)

Swagger allows combining and extending model definitions using the allOf property of JSON Schema, in effect offering model composition. allOf takes in an array of object definitions that are validated independently but together compose a single object.

While composition offers model extensibility, it does not imply a hierarchy between the models. To support polymorphism, Swagger adds the support of the discriminator field. When used, the discriminator will be the name of the property used to decide which schema definition is used to validate the structure of the model. As such, the discriminator field MUST be a required field. The value of the chosen property has to be the friendly name given to the model under the definitions property. As such, inline schema definitions, which do not have a given id, cannot be used in polymorphism.

@sergey-tihon
Copy link
Member Author

Fix is on the way
allof-props

@sergey-tihon
Copy link
Member Author

Released in v0.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant