Comments (8)
I can reproduce this issue at http://editor.swagger.io, by pasting the JSON listed above.
There seem to be two issues:
1. Parameters are missing the schema.
Not sure why this is required, it might be a bug, since both the editor and Swagger UI complain about schema missing.
By adding the schema to parameters, we solve this issue:
parameters:
- deprecated: false
allowEmptyValue: false
in: query
name: offset
description: offset description
required: false
schema:
type: integer
format: int64
- deprecated: false
allowEmptyValue: false
in: query
name: limit
description: limit description
required: false
schema:
type: integer
format: int64
2. Incorrect type specified for integer fields
In the JSON above, MyObject
has an id
field of type int
. The correct type is integer
, adding format int64
as follows:
MyObject:
type: object
properties:
name:
type: string
example: name of the object
id:
type: integer
format: int64
example: '100'
from swiftgger.
Hi @TofPlay.
Would you mind updating to version 1.3.0 to see if the PR above addresses your issue?
from swiftgger.
@eneko with version 1.3.0 I have the error
Errors
Hide
Fetch errorFailed to fetch http://locahost:8080/swagger.json
Fetch errorPossible cross-origin (CORS) issue? The URL origin (http://locahost:8080) does not match the page (http://localhost:8888). Check the server returns the correct 'Access-Control-Allow-*' headers.
When I check my server API I have:
$ curl -I http://localhost:8080/swagger.json
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,POST,HEAD,OPTIONS
Access-Control-Request-Headers: Content-Type, api_key, Authorization
content-type: application/json; charset=utf-8
content-length: 5791
date: Sun, 03 Feb 2019 21:08:16 GMT
Connection: keep-alive
It should be valid but has there something that does not like Swagger UI
from swiftgger.
To verify the spec generation is working, you can get the JSON output from http://localhost:8080/swagger.json
and paste it on http://editor.swagger.io (tap Ok to convert to YAML). Does is show you any validation errors?
If the spec is correct, then you might have an issue somewhere else. It seems, from your comment, you might have a mix of ports (8080 vs 8888).
from swiftgger.
To verify the spec generation is working, you can get the JSON output from http://localhost:8080/swagger.json
I tested with http://editor.swagger.io and the json is valid
you might have a mix of ports (8080 vs 8888)
Sure the server is running on port 8080 and Swagger UI is running has a docker image on port 8888
They are each in their environment but Swagger UI should be able to access the API server. During my first test I had no problem with CORS
from swiftgger.
Glad to hear the JSON output is valid 🎉
In regards of Swagger UI, this is probably outside of the realm of this library.
My understanding is both Swagger UI and the spec JSON file should live on the same hostname, to avoid any CORS issues. A couple of ideas to try:
- Serve Swagger UI from your server, as static files under a specific url path.
- Open your swagger UI index.html directly in the browser, or use
python -m SimpleHTTPServer
instead of Docker. If it's just for testing locally, it's faster and easier to setup.
Good luck!
from swiftgger.
In regards of Swagger UI, this is probably outside of the realm of this library.
@eneko You're right, thank you for your help 🙂
from swiftgger.
Happy to help and thank you for using Swiftgger! Let us know if you find any other issues with the JSON spec.
from swiftgger.
Related Issues (19)
- Compile error: "Reference to member 'value' cannot be resolved without a contextual type" HOT 1
- Custom Schema name HOT 9
- Nested Objects HOT 1
- Make OpenAPIDocument Decodable also
- Numbers(e.g. Integers or Floats) with Quotes/Doublequotes in examples
- Authorization header HOT 2
- Place OpenAPI on my server HOT 6
- Classes and Struct to APIObject HOT 5
- CamelCase to snake_case HOT 6
- Incorrect example value under Request Body HOT 6
- New version of Swiftgger built with swift 5.2 HOT 2
- Swiftgger upgrade issue
- Issue with plain text in 'Example Value' field HOT 1
- Issue with nested array of encodable objects HOT 4
- Dictionary object HOT 3
- Update APIResponse type
- APIObject Decimal and [[[T]]]
- OpenAPISecurityScheme: APIAuthorizationType produces a foreign "in" parameterLocation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftgger.