Git Product home page Git Product logo

Comments (13)

rhyde avatar rhyde commented on May 19, 2024 11

This is very unfortunate that there appears to be no interest in being compatible with existing standards.

from openapi-specification.

MikeRalphson avatar MikeRalphson commented on May 19, 2024 2

From this stackoverflow answer there are a few options mentioned.

A tool I wrote called jgeXml has a module for converting XSD to JSON schema (and particularly OpenAPI-flavour JSON schema). It isn't an exact 1:1 conversion, though it has been used to convert a complex 1,700+ line XML schema to build valid OpenAPI 2.0 schema objects, Feedback is welcome.

from openapi-specification.

benp444 avatar benp444 commented on May 19, 2024 2

OK, so given that there is no support for XML in Swagger, what is the commonly accepted work around where:

a) your data models are defined outside of the Swagger files and
b) you data models are defined in XSD.

My clumsy efforts have led me to the following Swagger file where I am using description to indicate to developers what they must expect in terms of payload definitions:

 post:
      summary: Creates a new student
      parameters:
        - name: StudentPerson
          in: body
          description: 'http://myOrg.com/schema/student/StudentPerson.xsd'
          schema:
            type: string

There must be some commonly accepted practice for using Swagger whilst at the same time stating "the payload should be based on this XML schema"

Can anyone provide some insight?

from openapi-specification.

jahlborn avatar jahlborn commented on May 19, 2024

Based on some feedback from the forum here ( https://groups.google.com/forum/#!topic/swagger-swaggersocket/hofujwEY6TY ), I will try to flush this out a little more.

Basically, swagger currently supports a limited sub-set of JSON Schema for describing models. The documentation alludes to the idea that you can use this to describe XML content as well as JSON content, but this only works in the simplest situation. The most obvious missing features would be the ability to describe XML attributes and XML namespaces. XML Schema, however, has the ability to describe most any reasonable XML structure (as well as plenty of unreasonable ones) and has extensive tooling support in a wide variety of languages, frameworks, and runtimes at this point in time. While swagger seems to have some good marketplace traction already, adding this support would allow swagger to branch out into a much wider variety of APIs, especially many existing APIs which already make extensive use of XML.

While even just the ability to embed XML Schema would be nice, similar to issue #58 , it would be even better to be able to reference external schema documents (both JSON and XML Schema).

So, ultimately, if all my dreams came true, i would see this issue resulting in:

  • The ability to define a Model using either JSON Schema or XML Schema (inline)
  • The ability to define a Model using a url which refers to an external JSON Schema or XML Schema document

from openapi-specification.

webron avatar webron commented on May 19, 2024

In Swagger 2.0, we've added support to finely define the translation to XMLs - https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#xmlObject.

from openapi-specification.

nize avatar nize commented on May 19, 2024

I am not sure I understand the spec, but to me it seems as you still can't reference XML Schema elements or types from your swagger spec. This would be a handy feature since you may have XML Schemas which you would like to reuse when you specify your API using swagger.

from openapi-specification.

webron avatar webron commented on May 19, 2024

That is correct. You cannot use XML schema to declare your models.

from openapi-specification.

ulaBLUE avatar ulaBLUE commented on May 19, 2024

Hi Ron,
I'm new to Swagger and would like to know if this still the case with new versions ? i.e can we use XML schema to define models ? Thanks.

from openapi-specification.

ePaul avatar ePaul commented on May 19, 2024

@ulaBLUE OpenAPI.next (what will become OpenAPI 3.0) is likely not to support other ways of defining schemas than the built-in schema language.

#764 proposed to allow schemas of different types, but this was withdrawn due to this being impossible to implement.

from openapi-specification.

darrelmiller avatar darrelmiller commented on May 19, 2024

@rhyde It is unfortunate that you have got that impression. Fortunately it is an inaccurate impression. We care very deeply about being compatible with existing standards. We also care about ensuring that tooling that implements the OpenAPI spec provides a consistent experience for users. Supporting schemas other than JSON Schema is something that many of us in the OpenAPI community want to be able to do. However, we need to do it in a way that meets all of our other goals and objectives. We were not able to do that in the V3 timeline. We definitely will be re-addressing this issue as we move forward and we look forward to your input and feedback on this important feature.

from openapi-specification.

sendtonirav avatar sendtonirav commented on May 19, 2024

Is there a tool that lets you automatically and reliably convert the XML schema (XSD) to the swagger supported JSON schema? Atleast that way I am managing one schema and then just auto converting it to the supported format?

from openapi-specification.

ioggstream avatar ioggstream commented on May 19, 2024

Work-in-progress here #1736

from openapi-specification.

slogic avatar slogic commented on May 19, 2024

ok, that thread is closed until oas 3.1.0 is ready. i see it is published 2 years ago. where is continuation of this thread?

from openapi-specification.

Related Issues (20)

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.