-
Notifications
You must be signed in to change notification settings - Fork 694
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
Export main types for v1 #147
Conversation
83d3d6c
to
ee8ba91
Compare
Two questions:
|
|
|
@runcom understood. A trivial review of the structs LGTM |
|
This seems totally crazy. What's the utility of json-schema if you can't On 16 June 2016 at 15:19, Vincent Batts [email protected] wrote:
|
cc @casualjim know of any json schema to Go struct generators? Our schema files are here: https://github.com/opencontainers/image-spec/tree/master/schema |
You can generate code from it with go-swagger. There is only one construct in use that go-swagger currently doesn't support. The oneOf here is currently not supported but we support a slightly different syntax to get that same effect (x-isnullable). This should get the generation process going:
|
Cool, we can work with that and maybe add a makefile target as well |
@casualjim thanks for the info |
last commit does a simple generation of the defs in the ./schema dir (just a test so everyone can see how they look like) |
|
||
/*ArrayOfGIds array of g ids | ||
|
||
swagger:model ArrayOfGIDs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't we already using jsonschema? Do we need to introduce yet another thing in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stevvooe please refer to comments above about using swagger.. (this is just a test commit to discuss if this is the way we would go with this generation)
so this is what swagger generates w/o the validation - runcom@5e32077 - I still have to find a way to generate validation only go files (because |
@runcom what's the latest here? |
@vbatts basically types are generated in runcom@5e32077. Validation isn't coming with that PR because |
Can you help me understand what is required? You want to split up the generated files in a file with the type definition and a file with the validation? I'd love to understand the reasons for it but let's start first with confirming intent. Would it be possible to submit an issue when you run into a blocker with swagger? |
On Mon, Jun 27, 2016 at 04:57:46PM -0700, Ivan Porto Carrero wrote:
Extrapolating from 1, I think the idea is to decouple the types It seems like that's what --skip-validator would be about, but we had |
I've added support for |
thx @casualjim - I've opened an Issue in swagger for validations |
Signed-off-by: Antonio Murdaca <[email protected]>
need a bunch of test fixing, on it |
actually looking at go-swagger/go-swagger#578 |
blocking again at |
@philips x-nullable comes from the swagger folks as the recommended work-around, I've seen both x-isnullable and x-nullable in use so we support both. I hope that for oas 3.0 there will be full support for json schema instead of the cherry-picking that was done for 2.0 |
I'm still fairly uncomfortable with this PR. The generated code and validation are of low quality and we don't end up with very solid godoc output. Without language-specific directives polluting the schema, I am not sure there is a resolution to this. It feels like this could have been done by now if we just did it by hand and validated against the schema after generation. Even with the generated code, we're still going to have to manually compare the specification with the generated implementations. If we can't get As far as I see it, there are a few options:
I'm sorry if this is not a majority opinion. In general, I agree with the sentiment of having this in place, so thank you @runcom for your work in this area. Let me know if I can help in any way to make this go along faster. |
type Annotations struct { | ||
|
||
|
||
MapStringString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is generated code, but this should be type Annotations map[string]string
.
I tend to agree with @stevvooe here as I'm not totally fond about going with go-swagger here for the same reasons he told us above. If anyone is interested I have the hand-written types in these patches: Which is basically doing the same as the "runtime-spec" project - no generated codes for types right now |
@runcom Those patches look great! |
What are the next steps here? Wait on using code generation, and pull in the hand done structs/types/etc? |
I'd go for my hand written one as runtime-spec is already doing due to the lack of an appropriate and clean code generation tool |
Sounds good. On Mon, Jul 18, 2016, 16:24 Antonio Murdaca [email protected]
|
Fix #133
/cc @stevvooe @vbatts @philips
This is basically how I expect those types to be exported and used in other tools.