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

Tag content always expanded #2799

Closed
hlubovac opened this issue Mar 27, 2017 · 20 comments
Closed

Tag content always expanded #2799

hlubovac opened this issue Mar 27, 2017 · 20 comments

Comments

@hlubovac
Copy link

docExpansion: "none" from v2 didn't work

@webron
Copy link
Contributor

webron commented Mar 27, 2017

Yes, it's noted in the Known Issues that most configuration options are not implemented yet.

@webron
Copy link
Contributor

webron commented May 30, 2017

For everyone who's interested in this feature (I imagine users will come here from the closed issues as well).

We understand the importance of this feature, however at the moment, we can't prioritize it very high (just limited resources). It would be great if anyone would attempt to submit a PR to add this functionality. I'm aware that our documentation is (very) lacking, but hopefully for those of you who know your javascript, following how some of the other configs work, would at least give you a hint as to what should be changed. If you have specific questions, we'll definitely try to help.

We're also in the process of writing up some guidelines to submitting PRs, that would help you and us in the process, but that shouldn't stop you from making changes. The basics are - make sure to add tests and if you need to add a distributed dependency, check with us first. We appreciate all the help we'll get, as I'm sure other users of this project. We'll do our best to review PRs as soon as possible, and make the process iterative as needed.

@hlubovac
Copy link
Author

do you have dev setup instructions anywhere

@webron
Copy link
Contributor

webron commented May 30, 2017

As mentioned, the documentation is lacking. Whatever is available can be found in the README.

@drjonnicholson
Copy link

Thanks @webron for the update (and consolidating the issues).

@hlubovac
Copy link
Author

hlubovac commented May 31, 2017

Never worked with docker. Installed. Ran its "hello world". Executed this

docker pull swaggerapi/swagger-ui
docker run -p 81:8080 swaggerapi/swagger-ui

(81, because my IIS is using 80)

"http://localhost:81/" displays the familiar "Swagger Petstore" (btw, it looks like v2).

I'm on Windows 10. My Hyper-V Manager is showing "MobyLinuxVM": I'm guessing this is the VM that contains the running swagger-ui site. Double-clicking that doesn't take me much further from "Connecting to 'MobyLinuxVM'" message, though (I had it sitting there for 10+ min).

I had some exposure to nodejs in the past, know my way around JS. I can't locate swagger-ui files to start editing. Or, is this just to run a precompiled and pre-installed version of swagger-ui in a docker VM?

Should I not be downloading the source to my local drive using git.exe, and then install dependencies via npm.exe, and run it using node.exe (then edit, test, push branch, create PR, etc)?

@webron
Copy link
Contributor

webron commented May 31, 2017

You don't need docker to develop. It's just https://github.com/swagger-api/swagger-ui#how-to-run.

@hlubovac
Copy link
Author

OK, works (finally).

So, to clarify: what's the requirement again? To display tags collapsed/uncollapsed, driven by a setting, that would be fed to SwaggerUIBundle function (accompanied by tests somehow)? I know I created this issue, but verifying just in case :)

Still not promising that this will work out, but I'll try.

@gwynjudd
Copy link
Contributor

@webron I tried npm run dev to see if it would pick up changes I made to the codebase and play around with it, but it disn't seem to pick up any changes I made (#3143) - is it supposed to pick up changes? Otherwise how to develop?

@hlubovac
Copy link
Author

hlubovac commented May 31, 2017

Nope; sorry: based on hints that I see around, this is all React syntax, which is beyond me. I was able to find that the relevant logic is in /src/core/components/operations.jsx ("is-open"; within the massive return statement), but I can't figure out how to wire that up with anything external. I don't even know how to debug this thing :(

Which IDE are you using?

@gwynjudd
Copy link
Contributor

@hlubovac these days I'm using vscode for pretty much all development unless I have to use something else. I tried even just changing the "isOpen" logic to just return false to see what would happen, but it seemed to have no effect at all, so I think there is some development step I was missing to get it to rebuild.

@hlubovac
Copy link
Author

hlubovac commented May 31, 2017

I did the following steps to make that run:

git clone https://github.com/swagger-api/swagger-ui.git ./swagger-api/swagger-ui
git checkout -b working

That path was just my choice, within a folder that I named "projects" :). Also the "working" branch name.
Then:

npm install

That took a while. Close to 900 folders within node_modules got downloaded/created.
Then:

npm run dev

That also isn't super quick. It seems that everything is getting "compiled" (transformed) from this JSX syntax to nodejs language. I didn't look around to see where the produced nodejs files get dumped (likely dist).

After that, http://localhost:3200 was showing v3 version of Petstore.

This compilation process seems to repeat each time I stop/start the service. But, then I also discovered that changes done within JSX files quickly get propagated all the way to the browse (I could see this in browser's console; no clue what mechanism is being used for this). So, I was able to see that my test change (I added a bogus value within quotes for className for the "is-open" and the opposite use-cases; line 49) gets communicated to the browser right away, as I could see my class-name value applied to the "section" element of a "tag", as it's being clicked to collapse/uncollapse.

So, hopefully that helps, if you know your way around React :)


I'm coding in VS, so I loaded all these files into an empty project, just to that I can browse and search quickly (as opposed to using Notepad :)), but that's irrelevant. VS doesn't provide any debugging features out-of-box for this lingo.

@gwynjudd
Copy link
Contributor

@hlubovac thanks for that, yes I can see that as well. I wasn't accustomed to how this reloading was working - I guess I was expecting to see it reload. OK I'll play around and see if I can affect the logic in any way

@gwynjudd
Copy link
Contributor

@hlubovac is this your plan for resolving #2710 (and similarly #1919)? Just wondering if we are trying to solve the same issue

@hlubovac
Copy link
Author

I just added a comment to #2710 as it being irrelevant to v3. So, not that one.

I wasn't aware of #1919, so not that one either.

I was trying to see if I'll be able to figure out a solution for this particular one (#2799), to have the "tag" content initially collapsed, driven by a startup setting, like this:

image

But, unfortunately, I don't know how to work with these code files (and I can't find time to get started at the moment), so I'm a fluke. :)

@gwynjudd
Copy link
Contributor

gwynjudd commented Jun 1, 2017

@hlubovac please try out my PR, I think it solves the issue

@hlubovac
Copy link
Author

hlubovac commented Jun 1, 2017

I downloaded your doc-expansion branch, and I see the change, but - which file did you add this to: docExpansion: "none" - to test the new setting?

@gwynjudd
Copy link
Contributor

gwynjudd commented Jun 1, 2017

Sorry, after I went to lunch I realised that wouldn't be clear. Just add it to the bundle config like so:

  // Build a system
  const ui = SwaggerUIBundle({
    url: "http://petstore.swagger.io/v2/swagger.json",
    dom_id: '#swagger-ui',
    docExpansion: 'none',
    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
    ],
    plugins: [
      SwaggerUIBundle.plugins.DownloadUrl
    ],
    layout: "StandaloneLayout"
  })

@hlubovac
Copy link
Author

hlubovac commented Jun 1, 2017

I added a comment to your PR. Hopefully it meets their standards. Thank you!

@ghost
Copy link

ghost commented Jun 28, 2017

@gwynjudd works perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants