Comments (3)
Just to collect the specs:
// Field is ignored by json package.
Field int `json:"-"`
This one is indeed missing and can be supported easily.
// the field is omitted from the object if its value is empty,
// as defined above.
Field int `json:"myName,omitempty"`
How should this be reflected in Swagger? It should not be in the "required" list (at the moment this is not filled).
What do you mean by "Fields tagged with strings" ?
from go-restful.
Right, omitempty is a bit tricky now that you mention it.. My use case is a common Response object that is returned in all my GET methods. The response object has a couple of common fields and then specific ones that are filled depending on method. Here is an example of that object:
type Response struct {
Code int `json:"code"`
Users *[]User `json:"users,omitempty"`
Items *[]Item `json:"items,omitempty"`
}
In this case I might have the resources /users and /items, and depending on resource either Users or Items will contain anything.
One idea would be to only emit the documentation listing for the field if the "template" object sent in has a instance of it (this was what I tried first myself before I realized that it didnt work at all). So if the code is like this ws.Writes(Response{Users:&[]User{}})
the user field would be included but not the items field.
However, Im not sure how to handle the case where a object is used twice (both Reads and Writes), and the template is different. (In my case this wont happen the way my code is structured)
The strings tag means that the field will be serialized as a string even if its a int or float: http://golang.org/pkg/encoding/json/#Marshal (I dont need this feature myself, but thought it would be good to handle it at the same time as the other json tags are dealt with.
from go-restful.
I created a new Issue #86 for getting support for the remaining part.
from go-restful.
Related Issues (20)
- Security - PRISMA-2022-0227 - High Sev - emicklei/go-restful/v3 module prior to v3.10.0 is vulnerable HOT 3
- using path.Join breaks the current api HOT 6
- The go-restful-swagger12 not support go-restful version 3 HOT 4
- Whether to support a unified request results interceptors HOT 1
- which PR broke the compatible against v3.10.0 HOT 1
- Flush don't work HOT 7
- Questions about WebService Path HOT 2
- Security is not exposed in RouteBuilder HOT 6
- Improper handling of empty POST requests. HOT 5
- Why were the patch versions for vulnerability (snyk id:SNYK-GOLANG-GITHUBCOMEMICKLEIGORESTFULV3-2435654) released so late? HOT 2
- default values of a slice field in a Go struct HOT 3
- Evaluation HOT 1
- List all request headers HOT 1
- unable to mock a request with selectedRoute HOT 1
- v3.11.1 checksum mismatch HOT 2
- bug: swagger type alias parse failure! HOT 1
- regex route path allows partial match HOT 5
- mis-route with multiple webservice and regex routeToken HOT 3
- detectWebService biased against webServices without path or rootpath HOT 1
- why use copy instead of loop HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-restful.