-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use deepObject serialization for objects in query (#1)
- Loading branch information
Showing
9 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/swaggest/usecase" | ||
) | ||
|
||
func queryObject() usecase.Interactor { | ||
u := struct { | ||
usecase.Interactor | ||
usecase.Info | ||
usecase.WithInput | ||
usecase.WithOutput | ||
}{} | ||
|
||
u.SetTitle("Request With Object As Query Parameter") | ||
|
||
type inputQueryObject struct { | ||
Query map[int]float64 `query:"in_query" description:"Object value in query."` | ||
} | ||
|
||
type outputQueryObject struct { | ||
Query map[int]float64 `json:"inQuery"` | ||
} | ||
|
||
u.Input = new(inputQueryObject) | ||
u.Output = new(outputQueryObject) | ||
|
||
u.Interactor = usecase.Interact(func(ctx context.Context, input, output interface{}) (err error) { | ||
var ( | ||
in = input.(*inputQueryObject) | ||
out = output.(*outputQueryObject) | ||
) | ||
|
||
out.Query = in.Query | ||
|
||
return nil | ||
}) | ||
|
||
return u | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters