Yaml generated by swagger API designer


#1

I’m new to Visual Paradigm and I’m trying the new swagger api design function.

With this diagram:

This is the generated yaml:


swagger: "2.0"
info:
title: "Classroom Rest API"
version: "1.0.0"
basePath: "/"
schemes:

  • "http"
    paths:
    /classroom/students:
    get:
    operationId: "list_students"
    responses:
    200:
    description: "OK"
    schema:
    $ref: "#/definitions/Classroom"
    definitions:
    Classroom:
    type: "object"
    properties:
    name:
    type: "string"
    students:
    type: “student”

My question is: why isn’t the Student class definition present in the yaml file ?

(I’m using Visual Paradigm Professional Edition 15.0 build 20180228)


#2

Never mind, it was my fault, I wasn’t defining the classes properly.

Now it works as expected:


swagger: "2.0"
info:
title: "Classroom Rest API"
version: "1.0.0"
basePath: "/"
schemes:

  • "http"
    paths:
    /classroom/students:
    get:
    operationId: "list_students"
    responses:
    200:
    description: "OK"
    schema:
    $ref: "#/definitions/Classroom"
    definitions:
    Classroom:
    type: "object"
    required:
    • "students"
      properties:
      name:
      type: "string"
      students:
      type: "array"
      items:
      $ref: "#/definitions/Student"
      Student:
      type: "object"
      required:
    • "classroom"
      properties:
      name:
      type: "string"
      age:
      type: "integer"
      format: "int32"
      classroom:
      $ref: “#/definitions/Classroom”

#3

Hi,

Thanks for your inquiry. We’ll support your first version (without association) too and keep you informed.


#4

That would be great, thanks


#5

Hi m.berta,

I would like to let you know our engineers had enhanced the Swagger generator which now support generate related classes who being used in response class. Please follow the article below update your software to patch build 20180238cc to get this enhancement.

Feel free to contact me for any help and wish you have a good day!

Best regards,
Rain Wong


#6

I confirm your fix solved the problem. Thanks a lot