Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Include multiple $ref'd swagger files #467

Merged

Conversation

Javakky-pxv
Copy link
Collaborator

@Javakky-pxv Javakky-pxv commented Jul 8, 2022

In my project, the routes file is long and there is a lot of content in each document that I would like to see in the Swagger UI.
I tried to include the response document in another file, referring to Using $ref, but the #definitions were not generated properly.
So we created a function to embed the JSON or YAML file in the project referenced by $ref.
Please check the README for the specific changes.

I thought about just scanning an external file and generating #definitions, but I thought it would be more convenient to have an embedding function, considering that I need to make a good reference to the main swagger.json.

@Javakky-pxv
Copy link
Collaborator Author

Sorry, but I'm tired today, and I'll provide a summary soon.

@Javakky-pxv Javakky-pxv force-pushed the javakky/loading-definition-ref branch 2 times, most recently from 2c4930c to d518503 Compare July 9, 2022 10:03
@Javakky-pxv Javakky-pxv changed the title WIP: Include multiple $ref'd swagger files Include multiple $ref'd swagger files Jul 9, 2022
@Javakky-pxv
Copy link
Collaborator Author

@kailuowang
We would like to get your feedback on this feature first, when you are free 🙇

@Javakky-pxv
Copy link
Collaborator Author

Here is an excerpt from the README

No #definitions generated when referencing other Swagger files

By placing a json or YAML file in conf/${dir}/${file} and referencing it with $ref in a comment, the file can be generated embedded in swagger.json.

example conf/routes file.

###
#  summary: Top Page
#  responses:
#    200:
#      $ref: './swagger/home_200.yml'
###
GET     /            controllers.HomeController.index

example conf/swagger/home_200.yml file.

description: success

Of course, writing schema etc. will also be embedded.

Generated swagger.json.

{
  "paths": {
    "/": {
      "get": {
        "operationId": "index",
        "tags": [
          "routes"
        ],
        "summary": "Top Page",
        "responses": {
          "200": {
            "description": "success"
          }
        }
      }
    }
  }
  ......
}

See the following document for information on how to refer to other files by "$ref".

https://swagger.io/docs/specification/using-ref/

Copy link
Collaborator

@kailuowang kailuowang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great to me. I like the idea. 🙏

@Javakky-pxv Javakky-pxv force-pushed the javakky/loading-definition-ref branch from d518503 to 29826c4 Compare July 9, 2022 15:43
@Javakky-pxv
Copy link
Collaborator Author

@kailuowang
Thanks for your comment!
Can I ask you to review the code as well......? (Perhaps you have already reviewed it?)

@kailuowang
Copy link
Collaborator

Yes I did.

@Javakky-pxv
Copy link
Collaborator Author

Thanks!

@Javakky-pxv Javakky-pxv merged commit f0ddd9e into iheartradio:master Jul 9, 2022
@Javakky-pxv
Copy link
Collaborator Author

@kailuowang
Is it possible to get a temporary release with -SNAPSHOT to test the impact of this change on my repository?
We can deal with any problems, so PLAY2.8 is no problem.

@Javakky-pxv Javakky-pxv changed the title Include multiple $ref'd swagger files Feat: Include multiple $ref'd swagger files Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants