-
Notifications
You must be signed in to change notification settings - Fork 37
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
ToSwaggerSchemaObject class #6
Comments
I think this is a great idea. I didn't realize model definitions could be specified as arrays.
Previously, I was specifying the type as
Similar to this: {
"description": "A complex object array response",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/VeryComplexType" /* just an object. */
}
}
} This would simplify things if we didn't have to deal with the I think all Request bodies / Response bodies should have external model definitions, where the name of the model corresponds to the name of the constructor. This means everything should be wrapped in a newtype, including primitives like 'string'. So it would look something like: newtype Id = Id String deriving Show
data User = User { uid :: Text } deriving Show
type API = "api" :> QueryParams "params" Param :> ReqBody '[JSON] Id :> Get '[JSON] User
// in definitions
{ "Id" : {
"type" : "string"
}
}
{ "User" : {
"type" : "object"
, "properties" : {
"uid" : "string"
}
}
} I'm ok with the definition you have proposed, I would just move the data SwaggerSchemaObject
= Array SwaggerSchemaObject -- not a list
| Boolean Bool
| Object SwaggerModel There's also a lot of information that I'm not allowing a user to specify on things like I think |
Note that in case of
This is specified for JSON Schema's Actually, Swagger specification is not that obvious :) I have been thinking and have come to a conclusion that it would be better to have a separate |
Yes, the swagger spec is not obvious at all in my opinion ;) |
I suppose a user could encode a tuple in haskell to a heterogenous list in javascript... > λ: encode (1 :: Int, "hey" :: String)
"[1,\"hey\"]" Why anyone would want to do this, I don't know :) I'd be interested to see how you model the specification. I had that idea originally, to create a separate |
@fizruk, this might interest you as well, http://hackage.haskell.org/package/jsonschema-gen |
@fizruk, I think together we can come up with something that works well 👍 |
@fizruk, Great work! Do you want |
@dmjio Yes, the idea is to get swagger model out of |
Lenses seem appropriate (servant-docs uses them as well). Otherwise, it looks fantastic 👍 |
Closed in #9. |
Add optional -static flag to cabal files
Until now, we have built against haskell-servant#6, but the release is based on the alternative in haskell-servant#7. tinylog does not split up `new` into a version with and a version without effects, but reads the `Settings` for a flag that determines whether effects should be had or not. haskell-servant#7 also lacks some helpers that were not general enough, so I've copied them verbatim from haskell-servant#6 into this commit.
Currently
SwaggerModel
is used for response/request body and this is bad:ToSwaggerModel
hard or impossible.I suggest we add classes and types according to swagger specification:
The text was updated successfully, but these errors were encountered: