dart-ogurets / dart-openapi-maven

A Maven dependency for use with the OpenAPI swagger Maven plugin
BSD 2-Clause "Simplified" License
27 stars 11 forks source link

Enum are local to classes, How to create global enum #95

Closed pmg1991 closed 1 year ago

pmg1991 commented 1 year ago

Describe the bug With given yaml below two enums are created which are local to each class

Expected behavior single OrderStatus enum created

To Reproduce Sample yaml OrderStatusUpdateReq: type: object properties: orderId: type: integer format: int64 orderStatus: type: string enum:

rvowles commented 1 year ago

You have embedded your enum, so the class is embedded as it is local to the OpenAPI type. If you want to make a global enum, create a first class object, e.g.:

components:
  schemas:
    OrderStatusType:
      type: string
     enum:
      - NONE
      -  PENDING
      - ...
      - 

and then use it as a $ref

pmg1991 commented 1 year ago

@rvowles Thanks, this got resolved by https://github.com/springdoc/springdoc-openapi/issues/232#issuecomment-748607672