raml-org / raml-spec

RAML Specification
http://raml.org
3.87k stars 857 forks source link

Parser replacing schema name reference by inline value #52

Open gmaggess opened 10 years ago

gmaggess commented 10 years ago

Hi there,

When parsing a raml file, whose body response references a previously defined schema (sample below)

  /{id}: 
    uriParameters: 
      id: 
        displayName: id 
        description: | 
          the unique id of the incident report 
        type: integer 
    get: 
      description: | 
        Retrieves the incident report with the specified id. 
      responses: 
        200: 
          description: | 
            OK. 
          body: 
            application/json: 
              schema: report 
              example: | 
                { 
                  "id": 20934, 
                  "title": "Lynn's Leaking Water Heater", 
                  "customer": 123, 
                  "createdon": "2014-01-20 23:15:03 EDT" 
                } 

the returned js literal, does not contain the schema name anymore, instead it replaces the name by the json schema value, as if it was an inline schema from the beginning.

Is there a way to change this behavior and have the parser return the schema name?

Cheers, George

dmartinezg commented 10 years ago

Hi @gmaggess, I would log this issue in @raml-org/raml-js-parser.

This is expected behaviour. The idea is that consumers of the RAML specification do not need to know if in the definition the name or the schema were used.

usarid commented 10 years ago

However, they might want to know for various reasons, such as documentation. It would probably be good to add such metadata in parallel with the metadata about resourceType and trait names.

Let's please file the issue and responses under the specific parser implementations. But it's also good to have here an issue as a candidate for the next version of the RAML spec, asking that the spec recommend (not mandate) that RAML processors preserve information about the names of schemas. On Jul 2, 2014 4:33 AM, "Damian Martinez Gelabert" notifications@github.com wrote:

Hi @gmaggess https://github.com/gmaggess, I would log this issue in @raml-org/raml-js-parser.

This is expected behaviour. The idea is that consumers of the RAML specification do not need to know if in the definition the name or the schema were used.

— Reply to this email directly or view it on GitHub https://github.com/raml-org/raml-spec/issues/52#issuecomment-47765133.

dmartinezg commented 10 years ago

I think that this would over complicate the parser's output: Adding metadata. This is just one possible source of metadata. There are a hundred more, and putting all of that into the output, would be just too much (IMHO).

In developing the parser we tried as much as possible to remove RAML manipulation in consumers, trying to get it to process as much as it can.

gmaggess commented 10 years ago

@usarid and @dmartinezg, in my use case I pull the raml file from the server, parse it and populate my RAML based service designer. Therefore, I want to be able to reverse engineer the same raml file that I sent early to the server. Does that make sense?