Comments (5)
Can you share your YAML?
Looks like you defined something as string when should be a dict
from flasgger.
@rochacbruno, the YAML is pasted below. It's also available in the Swagger editor like this if that's helpful:
- See the smartAPI Registry
- See Exposure API v0.0.1
- Select Swagger Edtor
What I'd really like to do is use the spec as a whole like it is below, including for validation. Is that an option? i.e. instead of splitting it up into separate operations.
swagger: '2.0'
info:
contact:
responsibleDeveloper: Data Translator Green Team
url: www.renci.org
email: [email protected]
responsibleOrganization: Data Translator Green Team
title: Exposure API
description: API for environmental exposure models for NIH Data Translator program
termsOfService: None Available
version: 0.0.1
host: renci.org
basePath: /DataTranslatorExposures/api
schemes:
- http
paths:
'/exposureValue/{exposure}':
get:
description: >-
Retrieve the computed exposure value for a given environmental exposure
factor, time period, and set of locations
operationId: getExposureValue
responses:
'200':
description: successful operation
schema:
type: array
items:
$ref: '#/definitions/Exposures'
parameters:
- name: exposure
in: path
description: 'The name of the exposure factor (currently limited to pm25, ozone).'
required: true
type: string
- name: stime
in: query
description: >-
The starting date to obtain exposures for (example 1985-04-12 is
April 12th 1985). Currently time of day is ignored.
required: true
type: string
- name: etime
in: query
description: >-
The ending date to obtain exposures for (example 1985-04-13 is April
13th 1985). Currently time of day is ignored.
required: true
type: string
- name: loc
in: query
description: >-
A description of the location(s) to retrieve the exposure for.
Locaton may be a single geocoordinate (example
'35.720278,-79.176389') or a semicomma separated list of
geocoord:dayhours giving the start and ending hours on specific days
of the week at that location (example
'35.720278,-79.176389,Sa0813;35.720278,-79.176389,other') indicates
Saturdays from 8am to 1pm is at one location and all other times are
at another location. Hours should be in 24 hours time using 2
digits, days of the week should be the first two characters of the
day.If the day of the week does not appear then the time periods
apply to all days (example
'35.720278,-79.176389,0614,35.731944,-78.852778,1424') gives two
time periods for all days. If hours do not appear then the time
period applies to all hours of the day (example
'35.720278,-79.176389,Sa,35.731944,-78.852778,Su').
required: true
type: string
- name: tres
in: query
description: >-
The temporal resolution to use for results, should be one of 'hour'
or 'day'. Default is 'day'
required: false
type: string
- name: tstat
in: query
description: >-
The statistic to use for results, should be one of 'max', 'mean', or
'median'. Default is 'max'
required: false
type: string
summary: Get exposure value for a given environmental factor
produces:
- application/json
'/exposureScore/{exposure}':
get:
description: >-
Retrieve the computed exposure score for a given environmental exposure
factor, time period, and set of locations
operationId: getExposureScore
responses:
'200':
description: successful operation
schema:
type: array
items:
$ref: '#/definitions/Exposures'
parameters:
- name: exposure
in: path
description: 'The name of the exposure factor (currently limited to pm25, ozone).'
required: true
type: string
- name: stime
in: query
description: >-
The starting date to obtain exposures for (example 1985-04-12 is
April 12th 1985). Currently time of day is ignored.
required: true
type: string
- name: etime
in: query
description: >-
The ending date to obtain exposures for (example 1985-04-13 is April
13th 1985). Currently time of day is ignored.
required: true
type: string
- name: loc
in: query
description: >-
A description of the location(s) to retrieve the exposure for.
Locaton may be a single geocoordinate (example
'35.720278,-79.176389') or a semicomma separated list of
geocoord:dayhours giving the start and ending hours on specific days
of the week at that location (example
'35.720278,-79.176389,Sa0813;35.720278,-79.176389,other') indicates
Saturdays from 8am to 1pm is at one location and all other times are
at another location. Hours should be in 24 hours time using 2
digits, days of the week should be the first two characters of the
day.If the day of the week does not appear then the time periods
apply to all days (example
'35.720278,-79.176389,0614,35.731944,-78.852778,1424') gives two
time periods for all days. If hours do not appear then the time
period applies to all hours of the day (example
'35.720278,-79.176389,Sa,35.731944,-78.852778,Su').
required: true
type: string
- name: tres
in: query
description: >-
The temporal resolution to use for results, should be one of 'hour'
or 'day'. Default is 'day'
required: false
type: string
- name: tscore
in: query
description: >-
The exposure score type to return. The accepted values vary by
exposure factor. For pm25 values are '7dayrisk', '14dayrisk' (NOT
COMPLETE)
required: false
type: string
summary: Get exposure score for a given environmental factor
produces:
- application/json
definitions:
Exposures:
type: object
properties:
values:
$ref: '#/definitions/Exposure'
Exposure:
type: object
properties:
stime:
type: string
format: dateTime
example: starting time for the given measure
value:
type: string
example: numerical or categorical depending upon type of value being requested
etime:
type: string
format: dateTime
example: ending time for the given measure
from flasgger.
Here's the repo. I've split the entire spec above into this and changed the operation definition to include a schema to take advantage of flasgger as follows:
Get environmental exposure value operation
---
swagger: '2.0'
info:
title: Exposure API
description: API for environmental exposure models for NIH Data Translator program
contact:
responsibleOrganization: Data Translator Green Team
responsibleDeveloper: Data Translator Green Team
email: [email protected]
url: www.renci.org
termsOfService: None Available
version: 0.0.1
host: exposures.renci.org
basePath: /api
schemes:
- [ "http", "https" ]
tags:
- Exposure
operationId: getExposureScore
parameters:
- name: body
in: body
required: true
schema:
id : exposureScoreRequestSchema
required:
- exposure
- stime
- etime
- loc
properties:
exposure:
description: 'The name of the exposure factor (currently limited to pm25, ozone).'
required: [ "true" ]
default: pm25
type: string
stime:
description: >-
The starting date to obtain exposures for (example 1985-04-12 is
April 12th 1985). Currently time of day is ignored.
required: [ "true" ]
default: '1985-04-12'
type: string
etime:
description: >-
The ending date to obtain exposures for (example 1985-04-13 is April
13th 1985). Currently time of day is ignored.
default: '1985-04-12'
required: [ "true" ]
type: string
loc:
description: >-
A description of the location(s) to retrieve the exposure for.
Locaton may be a single geocoordinate (example
'35.720278,-79.176389') or a semicomma separated list of
geocoord:dayhours giving the start and ending hours on specific days
of the week at that location (example
'35.720278,-79.176389,Sa0813;35.720278,-79.176389,other') indicates
Saturdays from 8am to 1pm is at one location and all other times are
at another location. Hours should be in 24 hours time using 2
digits, days of the week should be the first two characters of the
day.If the day of the week does not appear then the time periods
apply to all days (example
'35.720278,-79.176389,0614,35.731944,-78.852778,1424') gives two
time periods for all days. If hours do not appear then the time
period applies to all hours of the day (example
'35.720278,-79.176389,Sa,35.731944,-78.852778,Su').
required: [ "true" ]
default: '35.720278,-79.176389,Sa,35.731944,-78.852778,Su'
type: string
tres:
description: >-
The temporal resolution to use for results, should be one of 'hour'
or 'day'. Default is 'day'
required: [ "false" ]
type: string
tscore:
description: >-
The exposure score type to return. The accepted values vary by
exposure factor. For pm25 values are '7dayrisk', '14dayrisk' (NOT
COMPLETE)
required: [ "false" ]
type: string
produces:
- application/json
summary: Get exposure score for a given environmental factor
description: >-
Retrieve the computed exposure score for a given environmental exposure
factor, time period, and set of locations
responses:
'200':
description: successful operation
schema:
items:
$ref: '#/definitions/Exposures'
type: array
definitions:
Exposures:
type: object
properties:
values:
$ref: '#/definitions/Exposure'
Exposure:
type: object
properties:
stime:
type: string
format: dateTime
example: starting time for the given measure
value:
type: string
example: numerical or categorical depending upon type of value being requested
etime:
type: string
format: dateTime
example: ending time for the given measure
On the face of it, it doesn't seem like definitions really belong at the same level as an operation. It works great without that part. Anyway, any guidance is appreciated.
from flasgger.
I will try to reproduce your problem.
from flasgger.
@stevencox sent stevencox/exposures#1
from flasgger.
Related Issues (20)
- sdist is missing tox.ini
- Switch from `pep8` to `pycodestyle`
- Unable to use import in yaml definitions with relative path
- Unhandled error around self.SCHEMA_TYPES
- Schema with no required fields crashes
- disable swagger route until authorization HOT 3
- How can I protect the swagger endpoints, by making it a child of another existing endpoint? HOT 1
- Flassger support for parameter type:file HOT 3
- Query parameter not getting picked up in `parsed_data` after 0.9.5
- apispec is missing in the run-time requirements in setup.py
- 1 test fails: ModuleNotFoundError: No module named 'flasgger_package'
- Data validation with swag_from doesn't work with OpenAPI 3
- Not serving .js and .css files? HOT 1
- Duplicate API Versioning Prefix in Swagger UI Paths with Base URL Configuration
- flask-marshmallow - generating Marshmallow schemas from SQLAlchemy models seemingly breaks flasgger HOT 1
- swag_from default location
- Swagger interface allows the injection of JavaScript code
- Flasgger does not work because the uiversion is loaded as a string
- OpenAPI client generator docs link?
- swag_from with "schema": MyMarshmallowSchema always generates Swagger 2.0 style references
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 flasgger.