flasgger / flasgger

Easy OpenAPI specs and Swagger UI for your Flask API
http://flasgger.pythonanywhere.com/
MIT License
3.59k stars 518 forks source link

Support plain definition $ref #85

Open rochacbruno opened 7 years ago

rochacbruno commented 7 years ago

Currently we need $ref: '#/definitions/Color' and we should support $ref: Color

      Palette:
        type: object
        properties:
          palette_name:
            type: array
            items:
              $ref: '#/definitions/Color'
      Color:
        type: string

The idea is to support

      Palette:
        type: object
        properties:
          palette_name:
            type: array
            items:
              $ref: Color
      Color:
        type: string

Internally flasgger should transform $ref: Color in to $ref: '#/definitions/Color' in the json output.

rochacbruno commented 7 years ago
if data.get('$ref`):
   if not data['$ref'].startswith('#/definitions/'):
       data['$ref'] = "'#/definitions/{0}'".format(data['$ref'])
blazerguns commented 5 years ago

At the moment if I do

parameters:
  - in: body
    schema:
      id: SUpload
      type: object
      properties:
        metadata:
          schema:
          $ref: '#/definitions/UploadMetaProperties'
definitions:
  UploadMetaProperties:
    type: object
    properties:
      url:
        type: string
        format: url
        minLength: 2
        maxLength: 200

I get the following error when calling validate() Validation error for Unresolvable JSON pointer: 'definitions/UploadMetaProperties' Does that mean $ref is not supported? Is there a work around?

StefanBrand commented 3 years ago

@blazerguns watch your indents. $ref is on the same indentation level as schema, but it should be indented relative to schema.