Issue #1: Add a script for generating Swagger object definitions#2
Open
tomascohen wants to merge 1 commit intojoubu:masterfrom
Open
Issue #1: Add a script for generating Swagger object definitions#2tomascohen wants to merge 1 commit intojoubu:masterfrom
tomascohen wants to merge 1 commit intojoubu:masterfrom
Conversation
This patch adds a script that uses DBIC schema definitions to generate Swagger object defintiions. It generates generic descriptions for the fields until we make a decision on extending our schema metadata with those descriptions or even put them in the DB backend using MySQL'1 COMMENT It makes use of a template to generate its output because I belive we should keep the columns order for the swagger definition (documentation) so it became impossible to achieve by using JSON->to_json to output plain JSON data out of the hashref. Instead of that it uses arrays internally and use the template to arrange things. Pretty printing is done by an external tool: jq, which needs to be installed for running the script. The script will die with a message if the jq binary is not in the path. To test: - Run: $ sudo koha-shell kohadev k$ cd kohaclone k$ ../misc4dev/koha_schema_to_swagger.pl --class BorrowerAttribute => SUCCESS: The expected swagger definition is printed on the terminal Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch adds a script that uses DBIC schema definitions to generate
Swagger object defintiions. It generates generic descriptions for the
fields until we make a decision on extending our schema metadata with
those descriptions or even put them in the DB backend using MySQL'1 COMMENT
It makes use of a template to generate its output because I belive we
should keep the columns order for the swagger definition (documentation)
so it became impossible to achieve by using JSON->to_json to output
plain JSON data out of the hashref. Instead of that it uses arrays
internally and use the template to arrange things.
Pretty printing is done by an external tool: jq, which needs to be
installed for running the script. The script will die with a message
if the jq binary is not in the path.
To test:
$ sudo koha-shell kohadev
k$ cd kohaclone
k$ ../misc4dev/koha_schema_to_swagger.pl --class BorrowerAttribute
=> SUCCESS: The expected swagger definition is printed on the terminal
Signed-off-by: Tomas Cohen Arazi tomascohen@theke.io