swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Render models in UI code, not JS

Open fehguy opened this issue 11 years ago • 57 comments

This may be a duplicate, but we need to move the rendering of models out of swagger-js and into swagger-ui.

fehguy avatar May 07 '15 23:05 fehguy

  • [ ] add rendering of read-only attributes
  • [ ] update rendering in responses to show complete schemas for each response code. See https://github.com/swagger-api/swagger-ui/issues/671, https://github.com/swagger-api/swagger-ui/issues/640, https://github.com/swagger-api/swagger-ui/issues/1248, https://github.com/swagger-api/swagger-ui/issues/1055
  • [ ] add formats in rendering, https://github.com/swagger-api/swagger-ui/issues/1202
  • [ ] render examples in UI, not JS, https://github.com/swagger-api/swagger-ui/issues/1213
  • [x] XML examples #583, #744
  • [ ] Add map rendering #558
  • [ ] Consider different JSON renderer, #863

fehguy avatar May 07 '15 23:05 fehguy

Shouldn't there be an equivalent issue in swagger-js for removing it?

webron avatar May 09 '15 17:05 webron

Sorry but being new here, could someone tell how can I find out which release version has or will have this issue fixed?

makimat avatar May 20 '15 09:05 makimat

@makimat - we haven't set a plan for it yet.

webron avatar May 20 '15 12:05 webron

:+1: It appears the issue I mentioned over at https://github.com/swagger-api/swagger-spec/issues/303 is caused by this Basically when I try to use a mimetype for the produces like multipart/mixed, I can't get the example to show unless I use object, and then it shows in an undesirable way. String is the type that would work as a workaround, but it doesn't show.

yonderblue avatar Jun 03 '15 21:06 yonderblue

Also a big :+1: to getting readOnly to have meaning in the UI.

yonderblue avatar Jun 04 '15 00:06 yonderblue

+1 for showing model descriptions in the UI

sschwell avatar Aug 13 '15 20:08 sschwell

+1

jscti avatar Sep 15 '15 09:09 jscti

We would also really love to have support for the readOnly property!

alexkrishnan avatar Sep 21 '15 21:09 alexkrishnan

+1 for this feature!

treidco avatar Oct 02 '15 14:10 treidco

+1

matoushavlena avatar Oct 20 '15 20:10 matoushavlena

:+1:

JeroenDeDauw avatar Nov 29 '15 16:11 JeroenDeDauw

+1

luigibianchi avatar Dec 22 '15 08:12 luigibianchi

Hi, is there an update to when we will be able to document Maps for JSON responses? I'm trying to push Swagger in our organization and this is one of the things I have trouble explaining to the masses that we cannot show JSON schemas with maps.

cabbonizio avatar Dec 27 '15 15:12 cabbonizio

Simple maps are easy but complex maps (values which are complex models) are tricky. The most helpful input would be how you'd expect them to appear in both the sample and schema views

fehguy avatar Dec 27 '15 16:12 fehguy

@fehguy fair enough! I'll be in the office soon and will push some examples over to you. Stay tuned and thanks for your response.

cabbonizio avatar Dec 28 '15 12:12 cabbonizio

Here's what I propose @fehguy:

Here is the sample JSON. This a simple response of a map of product objects with the key being the product number.

{
    "products": {
        "01234": {
            "shortDescription": "Sample Product Description",
            "price": 100.00
        },
        "56789": {
            "shortDescription": "Another Sample Product Description",
            "price": 50.00
        }
    }
}

Here is how I propose (roughly!) it should look in the model schema view:

swagger

Here is how I propose (in YAML using Swagger editor) we define a map:

    Response:
      description: "Sample description"
      type: object
      properties:
        products:
          type: map
          key:
            description: "Product identifier"
            type: string
          value:
            $ref: "#/definitions/Product"
    Product:
      description: Product Object
      type: object
      properties:
        shortDescription:
          description: Sample description.
          type: string
        price:
          description: Price of product.
          type: number          

cabbonizio avatar Dec 28 '15 16:12 cabbonizio

I hope this helps @fehguy. I had a few developers at my desk to put this proposal together for maps as many of us in the organization are taking advantage of maps within our response models and we're all big fans of Swagger. As I said before this is one of the main missing pieces to complete our documentation. There are others questioning the use of Swagger due to this limitation and I'm trying to evangelize it. I hope the example above helps provide a general guideline what we're looking for and I know other users of the Swagger community have been asking for this. Thanks very much for your attention to this and hope there's something cool that comes out of this!

cabbonizio avatar Dec 28 '15 16:12 cabbonizio

thanks @cabbonizio this is a pretty easy fix in the short term. There are some limitations, though, that make it harder to support, such as in-line map definitions, etc.

fehguy avatar Dec 31 '15 20:12 fehguy

@fehguy, thanks for the response I'm excited to hear this would be an easy fix. Just curious, is this a "fix" or actually an "enhancement" since maps are currently not supported? Either way, I'm hoping maps will be available soon.

I agree, complex map definitions and in-line definitions would be challenging, but like anything else those can be incremental and if you show people Swagger can support maps, even if functionality is limited at the start, this is a step in the right direction.

Curious, how soon would I be able to test something out for map support?

cabbonizio avatar Jan 04 '16 18:01 cabbonizio