I'm trying to use Swagger to create API documentation for an API we're building and I've never used it before.
The documentation on Github says that the Resources Listing needs t be at /api-docs and the various resource files need to be at /api-docs/books etc.
This makes naming files and folders very tricky. I think they expect the files to have no file names, rather than having a folder called /api-docs it has to be an extension-less file, then you can't put the resources in an api-docs folder because you can't call the folder that, so they suggest using a folder called /listings.
This folder doesn't appear in the URL structure of your documentation though, it's kind of invisible because you set the baseURL in your resources to the proper path, but it looks like that has to be an absolute path, which is awkward if you want to have it on several servers (local and production).
Maybe I just don't get it but this all seems to be absolutely nuts.
So, I have 2 questions.....
1) Can I give my resource listing file and my resource files a .json extension? This would make sense as it's a JSON file.
2) Can I use a relative path to the resource listing file in the baseURL in my resource files?
Ideally, my file structure would be flatter, like this...
/api-docs
resources.json
books.json
films.json
Is Swagger flexible enough to do this?
It's an IIS server if that makes any difference (if the solution requires routing for example).
I was able to put model files into a folder under the web root and could reference them like this.
$ref: '/models/model.yml#/MyObject'
Relative paths also worked without a leading slash.
$ref: 'models/model.yml#/MyObject'
Inside the model.yml, I can reference other objects int eh same file like this
$ref: '#/MyObject2'.
However, I could only get the main swagger file to import model files. I could not get one model file to cross-reference another model file.
I was using a Tomcat web server but the principle will be the same.
Related
I have a NFS location that is not managed by me and it's contents can be accessed by browsing to it, i.d. the server is serving up the folder as a HTML page.
something like https://ftp.mozilla.org/pub/firefox/releases/52.0/
Is it possible to get the list of files in a JSON format response directly in the request response? Without changing anything on the NFS server and without having to write code to parse the HTML?
e.g., Maybe I can send the request to the URL with different headers.
To clarify:
When you access the address with a browser, curl or wget, you get a HTML page.
My motivation is that I don't want to mount the NFS location. I want to access the files by downloading them from the URL.
I don't know the type of server that is holding the shared folder.
Thanks.
In short, the answer is NO.
Not without tweaking the settings on the webserver that is serving the folder contents.
Here are some examples of how to tweak Apache to serve JSON formatted files listing for the folder.
Apache directory listing as JSON using PHP
Apache directory listing as json
Apache External Module mod_jsonindex - May not be the recommended way
http://1h.com/opensource/mod_jsonindex.html
I've implemented offline viewing based on the tutorial and github here. The problem I'm having is forge is looking for the db jsons in an odd location that makes url pathing awkward. The files in particular are 'objects_attrs.json.gz', 'objects_vals.json.gz', 'objects_offs.json.gz', 'objects_ids.json.gz', 'objects_avs.json.gz'. For some reason the forge viewer strips two layers of directories off the url then looks for the files there. Afterword Forge looks for the files in the original location but, looks for the straight json instead of the gziped jsons.
This can be handled in a few hacky ways like creating two arbitrary parent directories in the url and accepting files at the higher url as well. Or unzipping the gzips and saving them in location. But, these kind of hacks could easily be unstable if I'm not exactly right about the forge implementation.
Is there any reason these files are searched for in a different location? For example are these files also used by the 2d files not just the 3d files? Are there other files like this?
Look for the .svf file, say it's Design.svf. Rename it to Design.zip, and then upzip the file. This will get you the manifest.json.
Inside the manifest.json file, you'll file the URI's of all the files, including the one's you mentioned (the property database files).
Modify the URI as you wish, save the manifest.json file and re-zip it back up and rename it back to Design.svf.
If you got the URI path matching your file-system, then those property files will now load correctly.
Good luck!
I've started using a task runner to export all of my folders into a distribution folder using Gulp. The problem arises when I export images into the distribution folder, the path name is different from the one I'm using in my src file. So, as an example, when I target an image in HTML I type:
/assets/images/example.jpg
However, when the HTML file is distributed, it is supposed to target:
/images/example.jpg
It's still pointing to the assets folder, and creates a dead link. Should I be using a module like gulp-replace to automatically change these path names? Or should I just type in the assumed path name? Or, is there another method that I'm missing?
Sorry if I've phrased this badly, I'm working towards a new developer environment - let me know if I can provide you with any other details.
Should I be using a module like gulp-replace to automatically change
these path names?
Yes, gulp-replace will do the trick.
As an alternative you can place your index.html file into assets folder, so you don't need to change any paths when distributing the project.
The aim is to create a config file for server-side Dart application, which can be imported as needed into scripts like so:
import 'Config/config.dart';
What is crucial for this config script however, is that it knows it's own location when being accessed with an import (not the location of the file accessing it). Currently it uses this line below to find the path:
final String ROOT_DIR = dirname(Platform.script.toFilePath());
However, this returns the file path of the file importing it and not the file that is being imported. This needs to be known purely for working out a relative path to the root folder, which will allow other absolute paths to be known in the config file (such as routes, controllers, and things), like so:
final String PUBLIC_DIR = join(ROOT_DIR, 'Public');
final String VIEWS_DIR = join(ROOT_DIR, 'Views');
What would be the best way of approaching this? I have seen this post: Get script path in Dart (analog __DIR__ constant in PHP) which is the same sort of situation, however I can't see a clean way of using relative paths to find the route folder.
Probably missing something really obvious, but can't see it at the moment. Any help would be much appreciated, thank you for reading.
This is not supported in Dart.
Maybe Mezoni found some kind of trick to get this information which he packed in his caller_info package https://stackoverflow.com/a/24880092/217408.
You can't rely on the path where the files are stored during development.
Currently it is only experimental but when you run dart2dart on your code, all or many parts of the code are inlined.
I would like to allow my users to upload HTML content to my AppEngine web app. However if I am using the Blobstore to upload all the files (HTML files, css files, images etc.) this causes a problem as all the links to other files (pages, resources) will not work.
I see two possibilities, but both of them are not very pretty and I would like to avoid using them:
Go over all the links in the html files and change them to the relevant blob key.
Save a mapping between a file and a blob key, catch all the redirections and serve the blobs (could cause problems with same name files).
How can I solve this elegantly without having to go over and change my user's files?
Because app engine is running your content on multiple servers, you are not able to write to the filesystem. What you could do is ask them to upload a zip file containing their html, css, js, images,... The zipfile module from python is available in appengine, so you can unzip these files, and store them individually. This way, you know the directory structure of the zip. This allows you to create a mapping of relative paths to the content in the blobstore. I don't have enough experience with zipfile to write a full example here, I hope someone more experienced can edit my answer, or create a new one with an example.
Saving a mapping is the best option here. You'll need to identify a group of files in some way, since multiple users may upload a file with the same name, then associate unique pathnames with each file in that group. You can use key names to make it a simple datastore get to find the blob associated with a given path. No redirects are required - just use the standard Blobstore serving approach of setting the blobstore header to have App Engine serve the blob to the user.
Another option is to upload a zip, as Frederik suggests. There's no need to unpack and store the files individually, though - you can serve them directly out of the zip in blobstore, as this demo app does.