Giter Site home page Giter Site logo

shaded-enmity / ansible-schema-generator Goto Github PK

View Code? Open in Web Editor NEW
35.0 35.0 7.0 521 KB

Generate JSON schema for language servers from Ansible module documentation

License: GNU General Public License v3.0

Python 90.69% Shell 5.92% JavaScript 3.39%
ansible generator json-schema python2

ansible-schema-generator's Introduction

๐Ÿ”ฑ @shaded-enmity ๐Ÿ”ฑ

Build it, break it, rinse and repeat!

ansible-schema-generator's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ansible-schema-generator's Issues

[ansible 2.10] FQCN support

ansible recommends using FQCNs and tasks from ansible-base are on ansible.builtin namespace. Is it possible to add support for them?

Copy module's `mode` parameter should permit octal numbers or strings

Per the copy module's docs, the mode parameter may be either a string or an octal number.

Judging from the results I get with https://github.com/redhat-developer/yaml-language-server, I think this project generates a schema allowing only strings.

I say "I think" because I came here from https://github.com/SchemaStore/schemastore, which I believe is using this project to generate its Ansible schema.

That project currently has a bug report for this issue that has received no comments or response:

SchemaStore/schemastore#1018

and I thought this was probably the right place to bring it up for further discussion.

Should the generator map dict to object?

Hi @shaded-enmity according to this: ansible/ansible#42033 (review) I had to change the documentation to use dict instead of object.

Current code does not map the dict type:

TYPE_MAP = {
        'int': {'$ref': '#/definitions/ansible_number'},
        'bool': {'$ref': '#/definitions/ansible_truth'},
        'str': 'string',
        'float': 'number',
        'object': 'object'
    }

Is that the place to fix it? If so I can create a PR for it.

Playbooks are not supported

I am trying to use this schema with yaml-language-server. After setting everything up, I create a new yml file and start editing it. I want this file to be a playbook:

- hosts: all
  tasks:
    - apt:

The first issue is that I get no completions for the tasks. Then, hosts complains that it needs a shell property. From what I understand the schema file supports only yml files with tasks and not playbooks. Is this the case? If so, can playbook support be added? Is there an existing workaround?

Make the compound schema a JSON definition

Currently only the common "generic" types like number, truth etc are handled using definitions.

To enable using the schemas in a context of tasks embedded into roles and playbooks we should make the main schema a definition as well that we can further reference from sub schemas.

Error out on generating schema

Tried running the example from examples/ dir and whats getting run in test.sh. Both fail out with:

2021-11-03 23:05:28,152 [2044615] CRITICAL ansible-schema: Traceback (most recent call last):
  File "/home/mike/git/gh/ansible-schema-generator/./ansible-schema-generator", line 734, in <module>
    main()
  File "/home/mike/git/gh/ansible-schema-generator/./ansible-schema-generator", line 651, in main
    for filename, module in parsed_files.iteritems():
AttributeError: 'collections.OrderedDict' object has no attribute 'iteritems'

Installed requirements.txt. Anything I'm missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.