Skip to content

Commit

Permalink
Merge pull request #90 from masseelch/main
Browse files Browse the repository at this point in the history
feat(dsl): add Int() and UUID() builder
  • Loading branch information
ernado authored Dec 20, 2021
2 parents 4a229a3 + bbdcf50 commit 5927cf4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,9 @@ func (s *Schema) ToNamed(n string) *NamedSchema {
return NewNamedSchema(n, s)
}

// Int returns an integer OAS data type (Schema).
func Int() *Schema { return schema("integer", "") }

// Int32 returns an 32-bit integer OAS data type (Schema).
func Int32() *Schema { return schema("integer", "int32") }

Expand All @@ -971,6 +974,9 @@ func Double() *Schema { return schema("number", "double") }
// String returns a string OAS data type (Schema).
func String() *Schema { return schema("string", "") }

// UUID returns a UUID OAS data type (Schema).
func UUID() *Schema { return schema("string", "uuid") }

// Bytes returns a base64 encoded OAS data type (Schema).
func Bytes() *Schema { return schema("string", "byte") }

Expand Down
2 changes: 2 additions & 0 deletions dsl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var (
ogen.NewSchema().
SetDescription("A Pet").
AddRequiredProperties(
ogen.Int().ToProperty("required_Int"),
ogen.Int32().ToProperty("required_Int32"),
ogen.Int64().ToProperty("required_Int64"),
ogen.Float().ToProperty("required_Float"),
Expand All @@ -60,6 +61,7 @@ var (
ToProperty("required_enum_String"),
).
AddOptionalProperties(
ogen.UUID().ToProperty("optional_UUID"),
ogen.Int32().ToProperty("optional_Int32"),
ogen.Int64().ToProperty("optional_Int64"),
ogen.Float().ToProperty("optional_Float"),
Expand Down

0 comments on commit 5927cf4

Please sign in to comment.