Swagger came first. It was the API definition format and the tooling around it — Swagger UI, Swagger Editor, Swagger Codegen — and it gave the industry its first widely adopted common language for describing an HTTP API.
In 2015 the specification itself was donated to the newly formed OpenAPI Initiative under the Linux Foundation and renamed. Swagger 2.0 became the basis of OpenAPI 3.0. The name “Swagger” stayed with the tooling, which is now a commercial product family, while “OpenAPI” refers to the vendor-neutral specification.
In practice: if someone says “our Swagger file,” they usually mean an OpenAPI document, and quite often they mean a Swagger 2.0 document that has never been upgraded. Those are still very common in the wild and worth migrating — OpenAPI 3.x gave you the components object for reusable schemas and security schemes, proper request body modeling, and much better alignment with JSON Schema. OpenAPI 3.1 aligned with JSON Schema properly, which matters more than it sounds.
The naming confusion is mild compared to the value of what happened: the industry got a shared, machine-readable way to describe APIs, and it is stewarded in the open rather than owned by a vendor.