ebowman / api-first-hand

API-First bootstrapping tool for building RESTful web services from a Swagger/OpenAPI spec
MIT License
143 stars 22 forks source link

Using allOf with cross_spec doesn't generate import in model #23

Open pocman opened 8 years ago

pocman commented 8 years ago

Hi,

I have two models :

swagger: '2.0'
info:
  version: 1.0.0
paths:
definitions:
  entity:
    type: object
    properties:
      id:
        type: string
        format:  uuid
        example: "2ad91139-c3bc-420b-91a8-8aa9409aea07"
      created_at:
        type: string
        format: date-time
    required:
      - id
      - created_at

and

swagger: '2.0'
info:
  version: 1.0.0
paths:
definitions:
  point:
    allOf:
      - $ref: 'entity.yaml#/definitions/entity'

This generates two errors : target/scala-2.11/routes/main/model/point.yaml.scala:21: not found: type DateTime target/scala-2.11/routes/main/model/point.yaml.scala:21: not found: type UUID

As a fix, I'm adding this object to the definitions.

  import:
    description: This is only a fix for https://github.com/zalando/api-first-hand/issues/23
    type: object
    properties:
      uuid:
        type: string
        format:  uuid
      date_time:
        type: string
        format: date-time
pocman commented 8 years ago

There is the same issue with polymorphism if the definitions are not in the .yaml defining the endpoints.

When using a Cat in a /path, you can have a "not found: type IPet" error. This is really blocking since, using the above workaround doesn't work :/

  import:
    type: object
    properties:
      pet:
        $ref: 'pet_definition.yaml#/definitions/Pet'
lasomethingsomething commented 7 years ago

Hey @slavaschmidt, does this require any additional action?

slavaschmidt commented 7 years ago

@LappleApple yep, I think it's not in the master yet because of some other issues which are not fixed yet

lasomethingsomething commented 7 years ago

Thanks, @slavaschmidt :)