instrumenta / openapi2jsonschema

Convert OpenAPI definitions into JSON schemas for all types in the API
Other
226 stars 87 forks source link

I can not generate standalone schema #15

Closed liaoya closed 6 years ago

liaoya commented 6 years ago

I want to use kubeval to validate my Kubernetes yaml file but our CI/CD runner cannot access Internet. I want to package json schema to our docker image.

I want openapi2jsonschema generate schema directly instead of clone https://github.com/garethr/kubernetes-json-schema and copy the files to my container

To verfiy

docker run --rm -it python:3.6.6-slim /bin/bash
root@cf1b75c81ec1:/# pip install -Uq openapi2jsonschema
root@cf1b75c81ec1:/# cd
root@cf1b75c81ec1:~# openapi2jsonschema -o "master-standalone" --kubernetes --stand-alone https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json
Downloading schema
Parsing schema
Generating shared definitions
Generating individual schemas
Processing initializer
Generating initializer.json
An error occured processing initializer: ("Unresolvable JSON pointer: '/definitions/io.k8s.api.admissionregistration.v1alpha1.Rule'", {'$ref': '#/definitions/io.k8s.api.admissionregistration.v1alpha1.Rule'})
...

But I can run openapi2jsonschema -o "master" --kubernetes https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json

I need I use docker so that you can reproduce easily.

I look at https://raw.githubusercontent.com/garethr/kubernetes-json-schema/master/build.sh and generate my command

garethr commented 6 years ago

@liaoya the Dockerfile at https://github.com/garethr/kubeval/blob/master/Dockerfile.offline should do this I think. If not let me know.

liaoya commented 6 years ago

Hi, @garethr

I used this before and it did work. Thanks a lot of the wonderful kubeval.