GithubHelp home page GithubHelp logo

openapi-ts-sdk's People

Contributors

ajaxy avatar alekseyleshko avatar aroslov avatar collierrgbsitisfise avatar dependabot[bot] avatar dmlyapin avatar ichina avatar mikeshukshin avatar myandrienko avatar nikitarui92 avatar osome-bot avatar rendalf avatar rogozhin avatar runnez avatar snyk-bot avatar stuneak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ajaxy

openapi-ts-sdk's Issues

Invalid json-schema objects are generated

Description

If an object contains two or more properties with the same complex type, generated json-schema object is invalid.

Example

openapi.json

{
  "swagger": "2.0",
  "info": {
    "title": "Test API",
    "version": "{{version}}"
  },
  ...
  "paths": {
    "/foo/api": {
      "get": {
        "summary": "GET /foo/api",
        "description": "GET /foo/api",
        "operationId": "GET--foo-api",
        "responses": {
          "200": {
            "description": "",
            "schema": {
              "$ref": "#/definitions/TestResponse"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "TestResponse": {
      "type": "object",
      "properties": {
        "a": {
          "$ref": "#/definitions/CommonDefinition"
        },
        "b": {
          "$ref": "#/definitions/CommonDefinition"
        }
      }
    },
    "CommonDefinition": {
      "type": "object",
      "properties": {
        "foo": {
          "type": "string"
        }
      }
    }
  }
}

After compilation we receive following json-scheme object

{
  type: "object",
  properties: { 
    a: {
      type: "object",
      properties: { 
        foo: { 
          type: "string" 
        } 
      },
      $id: "default_CommonDefinition"
    }, 
    b: {
      type: "object",
      properties: { 
        foo: { 
          type: "string" 
        } 
      },
      $id: "default_CommonDefinition"
    }
  },
  $id: "default_TestResponse"
}

The problem is using the $id keyword that identifies a schema resource.

If you try to validate the object described below using ajv package, you will receive the following exception

Error: reference "#default_CommonDefinition" resolves to more than one schema

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.