[Container-tools] JSON Schema in Python Level 2

Maciej Szulik maszulik at redhat.com
Wed Nov 4 14:21:48 UTC 2015



On 11/04/2015 02:54 PM, Pavel Odvody wrote:
> On Wed, 2015-11-04 at 08:36 -0500, Aaron Weitekamp wrote:
>> On Wed, Nov 4, 2015 at 6:32 AM, Maciej Szulik <maszulik at redhat.com>
>> wrote:
>>> Both OpenShift and K8S rely on swagger library for generating
>>> schemas
>>> from Go code. I know there's a python counterpart [1] but I haven't
>>> tried it, maybe it'll be helpful for you guys.
>>>
>> +1. I would lean strongly towards current golang tools/patterns.
>>
>>
>>>   Maciej
>>>
>>> [1] https://github.com/digium/swagger-py/
>>>
>
> If I understand Swagger correctly it works the other way around - you
> write a specification and then let codegen create the code for you.

It can be used in that way as well. What we do is we setup swaggerapi
endpoint in openshift [1] which generates the schema from tags
(description) in the structures, see [2] for detailed information.

[1] 
https://github.com/openshift/origin/blob/master/pkg/cmd/server/origin/master.go#L160-L165
[2] https://github.com/emicklei/go-restful/tree/master/swagger

>>>
>>>
>>> On 11/03/2015 05:13 PM, Vaclav Pavlin wrote:
>>>> Hi all,
>>>>
>>>> As you probably know, we are using JSON Schema in Nulecule to
>>>> define the
>>>> specification. This let's us validate the Nulecule file against
>>>> the spec,
>>>> but that's all right now.
>>>>
>>>> There have been ideas to write a tool which will generate textual
>>>> representation from the schema and potentially a tool which could
>>>> generate
>>>> template Nulecule file from the schema.
>>>>
>>>> I always liked specs defined as structures in Go lang - they are
>>>> easy to
>>>> read and use. After a discussion with Pavel yesterday, he got an
>>>> idea which
>>>> got alive in his Github repository:
>>>>
>>>> https://github.com/rh-scp/metadata/blob/python-schema-1/schema/py
>>>> thon-impl.md
>>>>
>>>> Basically a way how to define a specification through Python
>>>> classes and
>>>> annotation (similarly to what can be done in Golang). I think
>>>> Nulecule
>>>> would be a great fit for this "experiment". IOW, we should try to
>>>> rework
>>>> the spec to the form Pavel is proposing to be able to a) generate
>>>> the spec
>>>> from code, b) use that code in Atomic App directly c) generate
>>>> the docs, d)
>>>> be able to generate Go lang structures from it in the future (and
>>>> thus make
>>>> it easy for anybody to just build on top of the spec)
>>>>
>>>> I'd like to propose it as a topic for this or next week Cabal and
>>>> get
>>>> someone assigned after the release.
>>>>
>>>> Comments can be added here:
>>>>
>>>> https://github.com/rh-scp/metadata/pull/2
>>>>
>>>>
>>>> Cheers,
>>>> Vašek
>>>>
>>>>
>
>




More information about the Container-tools mailing list