Jian Chen
Jian Chen

Reputation: 596

How can I retrieve io.swagger.models.Swagger object in a jersey+swagger-based system?

I want to get io.swagger.models.Swagger object in my system, which is a restful backend based on jersey and swagger.

I saw in class ApiListingResource there is such a statement

Swagger swagger = (Swagger) context.getAttribute("swagger");

, which can retrieve the swagger object from servlet context.

Can I do the same in my own code? This seems not a contract that the attribute name will always be "swagger". So I dare not.

Is there any reliable way to retrieve the object?

Upvotes: 0

Views: 213

Answers (1)

fehguy
fehguy

Reputation: 6824

You can rely on the context (yes, it is set to the name swagger, or with your own logic by extending BeanConfig

Upvotes: 1

Related Questions