Skip to content

ReadMe: myAPI variable in the example section is confusing #280

@kenozordi

Description

@kenozordi

In the example section of the README, the following code snippet uses a variable named myAPI:

SwaggerParser.validate(myAPI, (err, api) => {
  if (err) {
    console.error(err);
  } else {
    console.log("API name: %s, Version: %s", api.info.title, api.info.version);
  }
});

It’s not immediately clear what myAPI means or how it should be defined before this call.
For someone new to this tool, this could be confusing. It might refer to a file path, an object, or a URL.

It might be clearer to replace myAPI with something more descriptive like

// Path or URL to your Swagger/OpenAPI definition
const myAPI = "path/to/api.yaml";
SwaggerParser.validate(myAPI , (err, api) => {
  if (err) {
    console.error(err);
  } else {
    console.log("API name: %s, Version: %s", api.info.title, api.info.version);
  }
});

This small clarification would make the example easier to follow for new users and reduce confusion about how to use the validate() method correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions