question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema validation gives oneOf error when x- property is in parameter

See original GitHub issue

This schema fails due to the presence of x-ms-docs-key-type.

{
  "swagger": "2.0",
  "info": {
    "title": "oneOf parameter Fail",
    "version": "1.0"
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "test_op",
        "parameters": [
          {
            "in": "path",
            "name": "user-id",
            "description": "key: user-id",
            "required": true,
            "type": "string",
            "x-ms-docs-key-type": "user"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  }
}

This error is reported.

https://aka.ms/autorest
   Loading AutoRest core      'C:\Users\darrmi\.autorest\@microsoft.azure_autorest-core@2.0.4289\node_modules\@microsoft.azure\autorest-core\dist' (2.0.4289)
   Loading AutoRest extension '@microsoft.azure/autorest.csharp' (~2.3.79->2.3.82)
   Loading AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.55->2.3.55)
ERROR: Schema violation: Data does not match any schemas from 'oneOf'
    - file:///C:/Users/darrmi/test/psgraph/oneof-parameter-fail.json:11:8 ($.paths["/"].get.parameters)
FATAL: swagger-document/individual/schema-validator - FAILED

Extension properties should be allowed in parameters.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
fearthecowboycommented, Aug 4, 2020

Hmm. I think something changed a while back and I don’t recall when.

try --pass-thru:schema-validator-swagger for swagger (openapi2) or --pass-thru:schema-validator-openapi for OpenAPI3

Weird. I really don’t recall that getting split

1reaction
annaji-msftcommented, Aug 4, 2020

This helped --pass-thru:schema-validator-swagger

C:\Connectors-SDK>autorest --version:3.0.6306 --typescript --pass-thru:schema-validator-swagger --input-file:c:\Connectors-SDK\src\AzureConnectorsSdk.Tests\SampleFiles\office365-openapi.json AutoRest code generation utility [cli version: 3.0.6187; node: v12.16.3, max-memory: 8192 gb] © 2018 Microsoft Corporation. https://aka.ms/autorest Loading AutoRest core ‘C:\Users\anganti.autorest@autorest_core@3.0.6306\node_modules@autorest\core\dist’ (3.0.6306) Loading AutoRest extension ‘@microsoft.azure/autorest.typescript’ (~4.2.0->4.2.4) Loading AutoRest extension ‘@microsoft.azure/autorest.modeler’ (2.3.51->2.3.51) INFORMATION: The output folder doesn’t contain a pre-existing package.json file to get the package version from. [79.55 s] Generation Complete

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data does not match any schemas from 'oneOf' - Stack Overflow
Exiting. I can see in the swagger.json that the parameters property "name" is not generating correctly. Here it contains "body" whereas ...
Read more >
oneOf, anyOf, allOf, not - Swagger
Use the anyOf keyword to validate the data against any amount of the given subschemas. That is, the data may be valid against...
Read more >
LI81142: OPEN API VALIDATION ERRORS OF AN API ... - IBM
Swagger schema validation failed. Data does not match any schemas from 'oneOf' at #/parameters/x-requested-with Missing required property: schema at ...
Read more >
Understanding JSON Schema
4.11.5 Properties of Schema Composition . ... own car—er, writing their own JSON Schema validator—just yet. Note: This book describes JSON ...
Read more >
Handling Validation Errors - python-jsonschema
The full schema that this error came from. This is potentially a subschema from within the schema that was passed in originally, or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found