-- in.cue --
import (
	"time"
	"list"
)

let _time = time

#MyStruct: {
	timestamp1?: time.Time
	timestamp2?: time.Time()
	timestamp3?: time.Format(time.RFC3339Nano)
	timestamp4?: _time.Time
	date1?:      time.Format(time.RFC3339Date)
	date2?:      _time.Format(time.RFC3339Date)

	// This is not an OpenAPI type and has no format. In this case
	// we map to a type so that it can be documented properly (without
	// repeating it).
	timeout?: time.Duration

	contains: list.Contains("foo") // not supported, but should be recognized as list
}

-- out/TestGenerateOpenAPI/out.json --
{
   "openapi": "3.0.0",
   "info": {
      "title": "Generated by cue.",
      "version": "no version"
   },
   "paths": {},
   "components": {
      "schemas": {
         "Duration": {
            "type": "string"
         },
         "MyStruct": {
            "type": "object",
            "required": [
               "contains"
            ],
            "properties": {
               "timestamp1": {
                  "type": "string",
                  "format": "date-time"
               },
               "timestamp2": {
                  "type": "string",
                  "format": "date-time"
               },
               "timestamp3": {
                  "type": "string",
                  "format": "date-time"
               },
               "timestamp4": {
                  "type": "string",
                  "format": "date-time"
               },
               "date1": {
                  "type": "string",
                  "format": "date"
               },
               "date2": {
                  "type": "string",
                  "format": "date"
               },
               "timeout": {
                  "$ref": "#/components/schemas/Duration"
               },
               "contains": {
                  "type": "array"
               }
            }
         }
      }
   }
}