fastify / fastify-swagger

Swagger documentation generator for Fastify
MIT License
915 stars 201 forks source link

Remove swagger-ui #672

Closed Uzlopak closed 1 year ago

Uzlopak commented 1 year ago

Checklist

kibertoad commented 1 year ago

What is the rationale behind this change? This part of fastify-swagger is very widely used

Uzlopak commented 1 year ago

We want to remove swagger-ui from fastify-swagger and create a new plugin fastify-swagger-ui which has the swagger-ui part. see https://github.com/fastify/fastify-swagger-ui/pull/1

So based on that you can have e.g. a fastify-rapidoc impementation where you use fastify-swagger for swagger file generation and rapidoc as openapi viewer.

kibertoad commented 1 year ago

Makes sense. Then probably we first should release fastify-swagger-ui before this lands?

Uzlopak commented 1 year ago

I am still missing 3 code branches for 100% test coverage.

@kibertoad Thats why I point from initial implementation to this git branch. Also have some deactivated unit tests in fastify-swagger-ui, which have to work again.

kibertoad commented 1 year ago

We need to document migration path to fastify-swagger-ui somewhere

mcollina commented 1 year ago

@fastify/swagger-ui is out. Could you update this PR, make the CI pass, and add a migration plan?

Uzlopak commented 1 year ago

So! It seems that it is done code wise.

Now regarding the documentation: How should it be done?

I thought of:

Do you agree? Anything that I miss?

Btw. code review is welcome.

kibertoad commented 1 year ago

Create a Migrate_7_To_8.md (suggestion regarding name welcome)

Could be UPGRADE.md or MIGRATION.md

Uzlopak commented 1 year ago

I created the migration documentation. So please review it :)

Uzlopak commented 1 year ago

@mcollina PTAL

Uzlopak commented 1 year ago

So when we merge this and release, then we should do the follow up:

  1. Publish @fastify/swagger as 8.0.0
  2. merge https://github.com/fastify/fastify-swagger-ui/pull/6
  3. Publish @fastify/swagger-ui

It is utmost important to release a new version of @fastify/swagger-ui.

Uzlopak commented 1 year ago

@mcollina

Using now import for top level await.

gspetrou commented 1 year ago

Rando here who was really confused trying to set this up: @fastify/swagger 8.0 is published but @fasitfy/swagger-ui is not. Any ETA?

Uzlopak commented 1 year ago

@gspetrou I asked @mcollina . He wrote he will do it asap. But it might be tomorrow.

I apologize for the inconvenience.

gspetrou commented 1 year ago

No problem, impeccable timing on my part! Thanks

Uzlopak commented 1 year ago

@gspetrou It got released 🙏

Fdawgs commented 1 year ago

Thanks for working on this btw @Uzlopak. Never used the UI part in my APIs and it added an extra ~4MB to the build, which for some accounted for 20% of their size!

briceruzand commented 1 year ago

Great feature, because as you, I was not using swagger-ui. Until now, I was exposing my dynamic openapi spec via swagger at /documention/json to use it with rapidoc ui. But now routePrefix and exposeRoute options have been removed, how can I expose my dynamic openapi json spec with fastify-swagger ?

Thx

https://github.com/fastify/fastify-swagger/pull/672/files#diff-7aa4473ede4abd9ec099e87fec67fd57afafaf39e05d493ab4533acc38547eb8L62-L71

mcollina commented 1 year ago

You'll need to define the routes yourself:

https://github.com/fastify/fastify-swagger-ui/blob/master/lib/routes.js#L95-L115

dennys commented 11 months ago

routePrefix

Hi, I can use fastify-swagger with fastify-swagger-ui now, and I also can use RapicDoc to get the json. But I have the same question, how to expose my dynamic openapi json without fastify-swagger-ui. I try to read routes.js, but still have no idea. Could you give me some hits?

Eomm commented 11 months ago

Please open a new detailed issue to be useful for others

Spoiler: fastify.swagger()