Skip to content
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

[Proposal] Model generate command line option #1245

Closed
stealthycoin opened this issue Sep 18, 2019 · 4 comments
Closed

[Proposal] Model generate command line option #1245

stealthycoin opened this issue Sep 18, 2019 · 4 comments

Comments

@stealthycoin
Copy link
Contributor

stealthycoin commented Sep 18, 2019

Introduction

Proposal for #36

Proposed Interface

A new top level command chalice generate-models which will print out a model of the API to stdout.

The format of the models will be OpenAPI, in the future a --format flag can be added to support multiple formats.

Example

(chalice) ➜  tmp chalice new-project testproject
(chalice) ➜  tmp cd testproject
(chalice) ➜  testproject chalice generate-models
{
    "swagger": "2.0",
    "info": {
        "version": "1.0",
        "title": "testproject"
    },
    "schemes": [
        "https"
    ],
    "paths": {
        "/": {
            "get": {
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "responses": {
                    "200": {
                        "description": "200 response",
                        "schema": {
                            "$ref": "#/definitions/Empty"
                        }
                    }
                },
                "x-amazon-apigateway-integration": {
                    "responses": {
                        "default": {
                            "statusCode": "200"
                        }
                    },
                    "uri": "arn:aws:apigateway:{region_name}:lambda:path/2015-03-31/functions/{api_handler_lambda_arn}/invocations",
                    "passthroughBehavior": "when_no_match",
                    "httpMethod": "POST",
                    "contentHandling": "CONVERT_TO_TEXT",
                    "type": "aws_proxy"
                }
            }
        }
    },
    "definitions": {
        "Empty": {
            "type": "object",
            "title": "Empty Schema"
        }
    },
    "x-amazon-apigateway-binary-media-types": [
        "application/octet-stream",
        "application/x-tar",
        "application/zip",
        "audio/basic",
        "audio/ogg",
        "audio/mp4",
        "audio/mpeg",
        "audio/wav",
        "audio/webm",
        "image/png",
        "image/jpg",
        "image/jpeg",
        "image/gif",
        "video/ogg",
        "video/mpeg",
        "video/webm"
    ]
}
@jamesls
Copy link
Member

jamesls commented Sep 19, 2019

I think this would be good to add, especially as we add support for modeling inputs/outputs.

Looking over our chalice CLI commands, we're not consistent with what we have now, but we should try to not make it any more inconsistent:

Commands:
  delete
  deploy
  gen-policy
  generate-pipeline  Generate a cloudformation template for a...
  generate-sdk
  invoke             Invoke the deployed lambda function NAME.
  local
  logs
  new-project
  package
  url

I hate to bikeshed over this, but it seems like we should stick to gen-models or generate-models.

@stealthycoin stealthycoin changed the title [Proposal] Model export command line option [Proposal] Model generate command line option Sep 19, 2019
@stealthycoin
Copy link
Contributor Author

Updated for bikeshed. PR as well.

@stealthycoin
Copy link
Contributor Author

Closing since the PR was merged.

@MartijnHarmenzon
Copy link

Is there any documentation for this generate-models functionality?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants