swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
773 stars 526 forks source link

Schema's loaded from other than requested file don't store location #2057

Open maxlepikhin opened 4 months ago

maxlepikhin commented 4 months ago

setResolve(true) tells OpenAPIV3Parser to load specs from external locations and put them in the model.

  ParseOptions parseOptions = new ParseOptions();
  parseOptions.setResolve(true);
  OpenAPI openApiModel = new OpenAPIV3Parser().read(inputFile, null, parseOptions);

It is desirable to distinguish schemas loaded from external locations from the ones defined locally. For example:

On the other hand, api3.yaml may reference another file.yaml that must be resolved and included in the generated code for api3 unlike errors.yaml.

Proposal: store original reference in $originalRef next to $ref in SchemaProcessor.

This change will let code generators add custom logic for shared vs not schemas.