-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method designed without params/placeholders throws "missing path parameter placeholder in url"? #91
Comments
Full repro: import (
"reflect"
"testing"
"github.com/swaggest/jsonschema-go"
"github.com/swaggest/openapi-go"
"github.com/swaggest/openapi-go/openapi31"
)
type yodb_I64 int64
type None struct{}
func Test_Repro2(t *testing.T) {
oarefl := openapi31.NewReflector()
oarefl.Spec.Info.WithTitle("kaffe.local")
oarefl.JSONSchemaReflector().DefaultOptions = append(oarefl.JSONSchemaReflector().DefaultOptions, jsonschema.ProcessWithoutTags)
{
var dummy_in struct{ Id yodb_I64 }
var dummy_out None
ty_args, ty_ret := reflect.TypeOf(dummy_in), reflect.TypeOf(dummy_out)
op, err := oarefl.NewOperationContext("POST", "/_/postDelete")
if err != nil {
t.Fatal(err)
}
op.AddReqStructure(reflect.New(ty_args).Elem().Interface(), openapi.WithContentType("application/json"))
op.AddRespStructure(reflect.New(ty_ret).Elem().Interface(), openapi.WithHTTPStatus(200))
if err = oarefl.AddOperation(op); err != nil {
t.Fatal(err)
}
}
src_json, err := oarefl.Spec.MarshalJSON()
if err != nil {
t.Fatal(err)
}
t.Log(string(src_json))
} |
This behavior is due to a default option |
Sound good but already way past my openapi.json TODO (or the need for any dependency for that functionality) — feel free to Close the Issue at your leisure =) |
Using
v0.2.42
here,go get
ted just today.My error-raising request-struct looks like this:
struct { Id yodb.I64 }
which actually equates structurally/mem-wise tostruct { Id int64 }
.(It's an unnamed type so I guess
reflect.Type.Name
will be empty, but not sure. But that's not the cause — just double-checked by temporarily naming it.)My
Add
-ing code:op.AddReqStructure(reflect.New(ty_args).Interface(), openapi.WithContentType("application/json"))
This
error
s out with:Nothing after "link:". What's the idea? The underlying method expects a
{"Id": number}
payload and does not offer any url placeholdering/parametering. How and why is the assumption there?(Don't tell me the
_
in/_/postDelete
is interpreted as placeholder? That's a url-prefix for all our api-method paths, so that any non-_/*
path after/
is free as a user-claimable vanity-name/base-path, even sth. likeapis
😁 )From what I can tell:
AddOperation
callsSetupOperation
callsSanitizeMethodPath
which receives thepathPattern
of"/_/postDelete"
. I'd expectpathParametersSubmatches
to be empty for your{([^}:]+)(:[^}]+)?(?:})
regex (tried out quickly at regex101.com which said "no match").SetupOperation
should receivepathParams
as empty/nil, and yet clearly it doesn't — else the subsequentvalidatePathParams
wouldn't throw like I quoted above... mystifies me right now.The text was updated successfully, but these errors were encountered: