Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

TEMP: Remove check that blocks conflicting properties #356

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

daviwil
Copy link
Contributor

@daviwil daviwil commented Oct 5, 2020

Posting this for testing purposes, this is not the real fix.

Here is the tweaked Swagger based on @johanste's original example:

{
    "swagger": "2.0",
    "info": {
        "title": "Example of polymorphic models, hypothetical document recognition style",
        "version": "1.0"
    },
    "consumes": ["application/json"],
    "produces": ["application/json"],
    "paths": {
        "/analyze": {
            "post": {
                "operationId": "analyze",
                "parameters": [
                    {
                        "name": "fakeForm",
                        "in": "body",
                        "schema": {
                            "$ref": "#/definitions/AnalyzedForm"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successfully identied the type and contents of the document",
                        "schema": {
                            "$ref": "#/definitions/AnalyzedForm"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "AnalyzedForm": {
            "description": "Base model for arbitrary forms. Has an untyped set of fields that can be discovered",
            "type": "object",
            "required": [
                "docType",
                "fields"
            ],
            "discriminator": "docType",
            "properties": {
                "docType": {
                    "type": "string"
                },
                "fields": {
                    "$ref": "#/definitions/FormFields"
                }
            }
        },
        "FormFields": {
            "description": "Base model for collectoin of form fields. Has no known field names",
            "type": "object",
            "additionalProperties": {
                "$ref": "#/definitions/FormField"
            }
        },
        "FormField": {
            "type": "object",
            "discriminator": "propertyType",
            "required": [
                "propertyType"
            ],
            "properties": {
                "value": {
                },
                "precision": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                }
            }
        },
        "StringFormField": {
            "x-ms-discriminator-value": "string",
            "allOf": [
                {
                    "$ref": "#/definitions/FormField"
                }
            ],
            "type": "object",
            "properties": {
                "value": {
                    "type": "string"
                }
            }
        },
        "NumberFormField": {
            "x-ms-discriminator-value": "number",
            "allOf": [
                {
                    "$ref": "#/definitions/FormField"
                }
            ],
            "type": "object",
            "properties": {
                "value": {
                    "type": "number"
                }
            }
        },
        "DateFormField": {
            "x-ms-discriminator-value": "date",
            "allOf": [
                {
                    "$ref": "#/definitions/FormField"
                }
            ],
            "type": "object",
            "properties": {
                "value": {
                    "type": "string",
                    "format": "date"
                }
            }
        },
        "AnalyzedPassport": {
            "x-ms-discriminator-value": "passport",
            "allOf": [
                {
                    "$ref": "#/definitions/AnalyzedForm"
                }
            ],
            "properties": {

            }
        },
        "AnalyzedPassportFormFields": {
            "allOf": [
                {
                    "$ref": "#/definitions/FormFields"
                }
            ],
            "properties": {
                "issuingCountry": {
                    "$ref": "#/definitions/StringFormField"
                },
                "firstName": {
                    "$ref":  "#/definitions/StringFormField"
                }
            }
        },
        "AnalyzedBusinessCard": {
            "x-ms-discriminator-value": "form:businesscard",
            "allOf": [
                {
                    "$ref": "#/definitions/AnalyzedForm"
                }
            ],
            "properties": {
                "fields": {
                    "$ref": "#/definitions/AnalyzedBusinessCardFields"
                }
            }
        },
        "AnalyzedBusinessCardFields": {
            "properties": {
                "companyName": {
                    "$ref": "#/definitions/StringFormField"
                },
                "phoneNumber": {
                    "$ref": "#/definitions/StringFormField"
                }
            }
        }
    }
}

@azure-pipelines
Copy link

You may test this build by running autorest --reset and then either:


add --use: to the command line:

autorest --use:http://tinyurl.com/y2vqte2x ...


or use the following in your autorest configuration:

use-extension:
  "@autorest/modelerfour": "http://tinyurl.com/y2vqte2x" 

If this build is good for you, give this comment a thumbs up. (👍)

And you should run autorest --reset again once you're finished testing to remove it.

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

Successfully merging this pull request may close these issues.

1 participant