Skip to content

Change the way OpenAPI documents are loaded in v2 #1434

@darrelmiller

Description

@darrelmiller

Currently we have a set of OpenApiReaders to load OpenAPI documents. We have OpenApiStreamReader, OpenApiStringReader, OpenApiTextReader and OpenApiYamlDocumentReader. Each one of these a smaller number of methods. e.g. Read, ReadAsync, ReadFragment.

To use this object you must create the reader and then call a Read method. However, you generally only call a single Read method because it loads in the entire source content. Normally this pattern of using a Reader object is for when a client application wants to read in portions of a document and perform actions between those reads. That is not how we process documents.

This issue proposes that we move to the Load/LoadAsync/Parse pattern https://learn.microsoft.com/en-us/dotnet/api/system.xml.linq.xdocument.load?view=net-7.0 which is more consistent with our usage.

### Tasks
- [x] Define an interface for the format providers i.e YAML and JSON
- [x] Create a registry for managing the format providers
- [x] Implement the interface for each format provider i.e OpenApiJsonReader(lives in core lib) and OpenApiYamlReader(in readers lib)
- [x] Move loading code to the core lib
- [x] Create an OpenApiModelFactory class that abstracts the loading logic
- [x] Add static load methods on the OpenApiDocument class that call the factory
- [ ] https://github.com/microsoft/OpenAPI.NET/issues/1447

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions