Git Product home page Git Product logo

.github's People

Contributors

char0n avatar shockey avatar webron avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

.github's Issues

SwaggerParseResult need to have separate Warnings and Errors messages

SwaggerParseResult giving merged results of Warnings and Error. there is no way can clearly separate from this list.

public SwaggerParseResult deserialize(JsonNode rootNode, String path) {
SwaggerParseResult result = new SwaggerParseResult();
ParseResult rootParse = new ParseResult();
OpenAPI api = this.parseRoot(rootNode, rootParse, path);
result.setOpenAPI(api);
result.setMessages(rootParse.getMessages());
return result;
}

However required results available in OpenAPIDeserializer- ParseResult,, which is protected.

if SwaggerParseResult output gives or other way to get warnings and errors separately, that would be helpful.. People can use them whether the swagger is valid or not.

or

allow them ParseOption to disable warnings and just return errors.

Improvement: A menu alternative for "Refresh" and some other stuff (possible PR)

I've been using the Swagger UI tool, but I was missing a "Refresh" button, to refresh the URL that once was used to fetch the OpenAPI spec. Instead, I had to go to "Import URL" and add the URL every time I made a change to the spec in the backend code.

I did try to see if a page refresh (F5) had any effect, but it didnt. So, I cloned the repo, and made some small changes for me to run locally. I was considering a PR for this, but I read this, and here is the issue first for ppl to comment on =)

Changes I made locally, that I can make into a PR if ppl want it:

  • Added a menu alternative "Refresh":
    image
    Pressing this button, will re-download the specification from a url previously entered
  • topbar.jsx: added the refreshURL function, that looks in window.localstorage for the 'url' and refreshes it if it is found. If there is no cached URL, it will call the importFromURL instead, opening up the popup to enter URL
  • topbar.jsx:: added code to importFromURL so that the URL is cached in window.localstorage
  • Modified the logic for Clear editor in function clearEditor to also remove the url from localStorage
  • added a toast library, since I was lacking feedback for some actions (like when doing an 'Import from URL'); https://www.cssscript.com/super-simple-javascript-message-toaster-toast-js/#google_vignette
  • added toasts for both Refresh and the Import from URL options
    image

I am not a web dev or react dev, so I was unsure where to place the toast lib js file. Currently, it is inside the /dist folder, so the index.html is modified like this:

<body>
  <div id="swagger-editor"></div>
  <!--  https://www.cssscript.com/super-simple-javascript-message-toaster-toast-js/#google_vignette -->
  <script src="./dist/toast.min.js"> </script>
  <script src="./dist/swagger-editor-bundle.js"> </script>

Please let me know if I should make a PR out of this, or not =)

When using Swagger on Docker the parameter SWAGGER_JSON does not overwrite Petstore API documentation

Hi, how are you? I'm new here, so any comment will help me. Thanks in advance.

Context

  • OS: Docker
  • Browser: Firefox
  • Method of installation: Docker
  • Swagger-UI version: docker latest
  • Swagger/OpenAPI version: any

I'm trying to setup a Swagger container following the installation process. When I start the container in the basic way, I can access the Petstore API documentation on localhost:80. But, when I try to use the SWAGGER_JSON with the uber.json the Petstore API is still shown in localhost. I followed the tips from this previous issue #5213, but without success.

Here is the environment variables in docker showing the SWAGGER_JSON parameter is overwritten

docker exec -it distracted_greider /bin/sh
/ # printenv
BASE_URL=
SWAGGER_JSON=uber.json
HOSTNAME=261ba0107a21
SHLVL=1
PORT=8080
HOME=/root
PKG_RELEASE=1
TERM=xterm
NGINX_VERSION=1.23.3
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NJS_VERSION=0.7.9
API_KEY=**None**
SWAGGER_JSON_URL=
PWD=/

To reproduce

  1. Download the uber.json file
  2. Start the container according to documentation
docker run -p 80:8080 -e SWAGGER_JSON=uber.json -v foo:/bar swaggerapi/swagger-ui
  1. Access localhost
  2. The Petstore API documentation is shown

io.swagger.v3.core.util.Json public static method mapper() is not thread safe

The public static method mapper() like below is not thread safe. It appears that the "mapper" field is designed to be lazily initialized and only initialize once. But current implementation does not guarantee the mapper field is initialized only once. If we want the lazy and only once initialization semantic, we need to use double checked locking or simply synchronize the mapper() method, otherwise, the mapper has chance to be initialized multiple times.

current implementation:

    private static ObjectMapper mapper;

    public static ObjectMapper mapper() {
        if (mapper == null) {
            mapper = ObjectMapperFactory.createJson();
        }
        return mapper;
    }

suggested implementation using double checked locking

public static ObjectMapper mapper() {
        if (mapper == null) {
            synchronized(Json.class) {
                if (mapper == null) {
                    mapper = ObjectMapperFactory.createJson();
                }
        }
}
        

Generated enum classes of type Integers faling to deserialize JSON using Jackson 2.10.x and higher version.

We detected an issue during the json deserialization using the Jackson library 2.11.2 version.

The enum classes generated with the swagger open API 3.0 generator plugin are causing Jackson to throw exception when trying to deserialize the json using Jackson library 2.10.x and above versions.

The issue is happening when a swagger yaml has a type declared with the enum type of Integer in the spec, and the generated code trying to deserialize the json.

I have created a PR #904 with a possible fix and tested it with different Java types on my machine. Kindly take a look and approve if you think it looks good.

sample yaml with an enum Integer:

Count:
type: Integer
enum:
- 1
- 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.