raml-org / raml-js-parser

(deprecated) A RAML parser based on PyYAML written in CoffeScript and available for use as NodeJs module or in-browser.
195 stars 53 forks source link

Schema references in resource methods aren't code generation friendly #183

Open aschekatihin opened 8 years ago

aschekatihin commented 8 years ago

At the moment parser generates raml model object three with body or response sections that look like this:

"responses": {
    "200": {
        "body": {
            "application/json": {
                "schema": "{\"$schema\": \"http://json-schema.org/draft-04/schema\"}"
                }
            }
        }
    }
},

Schema name is lost at this point and replaced with schema content (JSON). We are creating custom code generator and need original schema name there, so it would be nice to have structure like this:

"responses": {
    "200": {
        "body": {
            "application/json": {
                "schemaName": "User",
                "schema": "{\"$schema\": \"http://json-schema.org/draft-04/schema\"}"
                }
            }
        }
    }
},

Or like this, but it will be breaking change for everyone relying to current structure:

"responses": {
    "200": {
        "body": {
            "application/json": {
                "schema": {
                    "name": "User",
                    "content": "{\"$schema\": \"http://json-schema.org/draft-04/schema\"}"
                }
            }
        }
    }
},