question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot generate global `parameters` node using Java annotations

See original GitHub issue

I have a bunch of JAX-RS 2.0 interfaces that define my API. I’m using Swagger 2.0 annotations to produce an OpenAPI 3.0 spec.

Many of the operations in the API share certain query and header parameters (things like language, client version, etc). It would be incredibly excessive and a nightmare to maintain if we just copied and pasted these shared parameters onto each operation.

Ideally, we’d like to blanket apply all of these parameters to our operations, but there doesn’t seem to be support for that in OpenAPI 3.0. The orthodox way to do this seems to be to use $ref to refer to parameters defined at the global API level.

There doesn’t seem to be any way to produce that global parameters node using just Swagger annotations, though. Is this a gap in functionality, or am I missing how to do this?

As an implementation, I’d expect to see a parameters field in the @OpenAPIDefinition annotation.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:6

github_iconTop GitHub Comments

4reactions
andreaangiolillocommented, Apr 23, 2021

+1 on the addition of @Components

1reaction
catbrefcommented, Dec 7, 2018

Looking at the OpenAPI v3.0 spec it might be better, or even easier, to add a @Components annotation for use inside @OpenAPIDefinition. Then inside @Components any number of @Parameter or @Schema or anything else as mentioned here: https://swagger.io/specification/#componentsObject

[Edit: quoting annotations]

Read more comments on GitHub >

github_iconTop Results From Across the Web

No @XmlRootElement generated by JAXB - Stack Overflow
The simple answer is that absence of an @XmlRootElement annotation is no problem if you marshal a JAXBElement. The thing that confused me...
Read more >
Java Annotations for DynamoDB - AWS Documentation
This section describes the annotations that are available for mapping your classes and properties to tables and attributes in Amazon DynamoDB.
Read more >
Customizing JAXB Bindings
Note that <javadoc> declarations cannot be applied globally--that is, they are only valid as a sub-elements of other binding customizations.
Read more >
How to Resolve The Cannot Find Symbol Error in Java - Rollbar
In the majority of cases, referencing undeclared variables and methods, including by way of misspelling them or failing to import their ...
Read more >
Developing with Spring Boot
In practice, you do not need to provide a version for any of these dependencies in your build configuration, as Spring Boot manages...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found