Conversation
|
Sorry about that! That looks like it's my bad. |
|
Don't beat yourself up, we still love you. |
|
Although, I just tried from master, and I don't see the issue you're mentioning. |
|
Mind sharing a test? I just redid it and it was the same. I added this to docparser/user.go: // TestSadzeih
// @openapi:schema
type TestSadzeih struct {
Signals Signals
}I ran a make test (which does not run the tests I just realised ^^), and here was the result: TestSadzeih:
type: object
properties:
Signals:
$ref: '#/components/schemas/'This was on upstream master. |
// @openapi:schema
type TestStruct struct {
Hello string `json:"hello"`
}
// @openapi:schema
type TestArray []TestStructGives me: TestArray:
type: array
items:
$ref: '#/components/schemas/TestStruct'
TestStruct:
type: object
properties:
hello:
type: string
|
// @openapi:schema
type TestStruct struct {
Hello string `json:"hello"`
}
// @openapi:schema
type TestWrapStruct struct {
Wrap TestStruct `json:"wrap"`
}Gives me: TestStruct:
type: object
properties:
hello:
type: string
TestWrapStruct:
type: object
properties:
wrap:
$ref: '#/components/schemas/TestStruct' |
|
Seems to me your test is not exactly what I am pointing out, you are creating an array of a struct (which works) but not using that new Type as a field in another struct. |
|
Hmm. I got confused by the first example in the description of the PR. I do have the issue when using the slice type in another struct. |
|
Because I messed up in it :D Editing that right now. |
|
So @Sadzeih, what do you think of the implementation? |
| return | ||
| } | ||
| refSplit[3] = meta.CustomName() | ||
| switch meta.Type { |
There was a problem hiding this comment.
So, this implem works, but I actually found where the ACTUAL issue is. This is more of a hack.
It works with struct thanks to this:
openapi-parser/docparser/model.go
Line 571 in 01dbd97
But this is not done for map or array. Everything should happen in:
openapi-parser/docparser/model.go
Line 520 in 01dbd97
There was a problem hiding this comment.
I'm guessing this would put the name of the alias as $ref which is what it did before the "break" so that's good.
Though I was considering going further and replacing it altogether by the target of the alias.
There was a problem hiding this comment.
I think that may require a bit of a rework, if I'm not mistaken. But I wouldn't mind the change, if you're up for it.
There was a problem hiding this comment.
@denouche Do you have time to review this one?
There was a problem hiding this comment.
Hey, sorry for the delay. I just took the time to read this thread.
If I understand well the debate is what to do between:
- going further and replacing it by the target of the alias
- or just fixing the initial issue
?
There was a problem hiding this comment.
Sorry for the delay as well, don't know how I missed your reply.
I think it could be done iteratively, first avoiding the issue and then going further but I would have to retest with new changes first.
|
Hey Guys, I ran into this same issue and I'm glad to see that PR! I will check on my side and let you know 🤞 |
|
Having a nil pointer dereference when generating the doc across my code, investigations in progress. |
Hi guys,
There was a small "regression" (might not have been planned to work before anyway) following commit 2d9c7ef.
What it changed is that now when using aliases for slices, the ref will not be properly filled. Here is a small example, related to the following code:
What it did before:
What it does now:
My changes attempt to fix that, even going a bit further by replacing the alias by the actual struct
What my changes does:
I admit I would go further and remove the Signals schema altogether from the generated documentation but wanted your thoughts on the whole thing before moving further.
@Sadzeih ? @denouche ?
Thanks in advance