nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ogen-go/ogen
Pull request #87 (2021-12-19 11:51:11)

feat(dsl): set schema type to "object" if properties are set


Patch:
diff --git a/dsl.go b/dsl.go
index 961801c5..c1e2eabe 100644
--- a/dsl.go
+++ b/dsl.go
@@ -790,6 +790,7 @@ func (s *Schema) SetFormat(f string) *Schema {
 
 // SetProperties sets the Properties of the Schema.
 func (s *Schema) SetProperties(p *Properties) *Schema {
+	s.SetType("object")
 	if p != nil {
 		s.Properties = *p
 	}
@@ -798,6 +799,7 @@ func (s *Schema) SetProperties(p *Properties) *Schema {
 
 // AddOptionalProperties adds the Properties to the Properties of the Schema.
 func (s *Schema) AddOptionalProperties(ps ...*Property) *Schema {
+	s.SetType("object")
 	for _, p := range ps {
 		if p != nil {
 			s.Properties = append(s.Properties, *p)


Test patch:
diff --git a/dsl_test.go b/dsl_test.go
index e70da0b8..4ccd4d88 100644
--- a/dsl_test.go
+++ b/dsl_test.go
@@ -129,6 +129,7 @@ func TestBuilder(t *testing.T) {
 							Description: "Success",
 							Content: map[string]ogen.Media{
 								string(ir.ContentTypeJSON): {Schema: ogen.Schema{
+									Type:        "object",
 									Description: "Success",
 									Properties: []ogen.Property{
 										{Name: "prop1", Schema: &ogen.Schema{Type: "integer", Format: "int32"}},
@@ -168,6 +169,7 @@ func TestBuilder(t *testing.T) {
 					Description: "An Error Response",
 					Content: map[string]ogen.Media{
 						string(ir.ContentTypeJSON): {Schema: ogen.Schema{
+							Type:        "object",
 							Description: "Error Response Schema",
 							Properties: []ogen.Property{
 								{Name: "code", Schema: &ogen.Schema{Type: "integer", Format: "int32"}},
@@ -342,7 +344,7 @@ func TestBuilder(t *testing.T) {
 	assert.Equal(t, &ogen.Schema{
 		Ref:              "ref",
 		Description:      "desc",
-		Type:             "string",
+		Type:             "object",
 		Format:           "",
 		Properties:       []ogen.Property{{Name: "prop"}},
 		Required:         []string{"prop"},
Repository: ogen-go/ogen
Pull request #90 (2021-12-20 14:11:10)

feat(dsl): add Int() and UUID() builder


Patch:
diff --git a/dsl.go b/dsl.go
index c1e2eabe..84822d97 100644
--- a/dsl.go
+++ b/dsl.go
@@ -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") }
 
@@ -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") }
 


Test patch:
diff --git a/dsl_test.go b/dsl_test.go
index 4ccd4d88..c5ae189b 100644
--- a/dsl_test.go
+++ b/dsl_test.go
@@ -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"),
@@ -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"),
Repository: ogen-go/ogen
Pull request #236 (2022-03-09 00:38:04)

fix(gen): remove unneeded parenthesis


Patch:
diff --git a/gen/_template/security.tmpl b/gen/_template/security.tmpl
index c2c4db35..069ce2ba 100644
--- a/gen/_template/security.tmpl
+++ b/gen/_template/security.tmpl
@@ -61,7 +61,7 @@ func (s *Client) security{{ $s.Type.Name }}(ctx context.Context, operationID str
 		req.Header.Set({{ quote $s.ParameterName }}, t.APIKey)
 		{{- else if $s.Kind.IsQuery }}
 		q := req.URL.Query()
-		q.Set({{ quote $s.ParameterName }}), t.APIKey)
+		q.Set({{ quote $s.ParameterName }}, t.APIKey)
 		req.URL.RawQuery = q.Encode()
 		{{- else }}
             {{ errorf "unexpected security %q:%q" $s.Kind $s.Format }}


Test patch:
diff --git a/_testdata/positive/test_query_api_key.json b/_testdata/positive/test_query_api_key.json
new file mode 100644
index 00000000..5f5b481a
--- /dev/null
+++ b/_testdata/positive/test_query_api_key.json
@@ -0,0 +1,75 @@
+{
+  "openapi": "3.0.3",
+  "info": {
+    "title": "title",
+    "version": "v0.1.0"
+  },
+  "paths": {
+    "/healthz": {
+      "get": {
+        "operationId": "probeLiveness",
+        "description": "Liveness probe for kubernetes",
+        "security": [
+          {
+            "QueryKey": []
+          }
+        ],
+        "responses": {
+          "200": {
+            "description": "User info",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "string"
+                }
+              }
+            }
+          },
+          "default": {
+            "$ref": "#/components/responses/Error"
+          }
+        }
+      }
+    }
+  },
+  "components": {
+    "schemas": {
+      "Error": {
+        "description": "Represents error object",
+        "type": "object",
+        "properties": {
+          "code": {
+            "type": "integer",
+            "format": "int64"
+          },
+          "message": {
+            "type": "string"
+          }
+        },
+        "required": [
+          "code",
+          "message"
+        ]
+      }
+    },
+    "responses": {
+      "Error": {
+        "description": "General Error",
+        "content": {
+          "application/json": {
+            "schema": {
+              "$ref": "#/components/schemas/Error"
+            }
+          }
+        }
+      }
+    },
+    "securitySchemes": {
+      "QueryKey": {
+        "type": "apiKey",
+        "in": "query",
+        "name": "key"
+      }
+    }
+  }
+}