GithubHelp home page GithubHelp logo

Comments (5)

rochacbruno avatar rochacbruno commented on May 18, 2024

Can you share your YAML?

Looks like you defined something as string when should be a dict

from flasgger.

stevencox avatar stevencox commented on May 18, 2024

@rochacbruno, the YAML is pasted below. It's also available in the Swagger editor like this if that's helpful:

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.

stevencox avatar stevencox commented on May 18, 2024

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.

rochacbruno avatar rochacbruno commented on May 18, 2024

I will try to reproduce your problem.

from flasgger.

rochacbruno avatar rochacbruno commented on May 18, 2024

@stevencox sent stevencox/exposures#1

from flasgger.

Related Issues (20)

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.