Giter Club home page Giter Club logo

Comments (4)

TomAugspurger avatar TomAugspurger commented on August 23, 2024

I also came across https://api.stacspec.org/v1.0.0-beta.1/core/#operation/getLandingPage.

https://github.com/TomAugspurger/stac-fastapi/tree/fix/landing-stac-version has a test that we match that spec. There are some missing things

>       assert result == expected
E       AssertionError: assert {'description...ion', 'title'} == {'conformsTo'...version', ...}
E         Extra items in the right set:
E         'conformsTo'
E         'id'
E         Full diff:
E           {
E         -  'conformsTo',
E            'description',...
E
E         ...Full output truncated (7 lines hidden), use '-vv' to show

tests/resources/test_conformance.py:12: AssertionError

For at least id, I think that's because the version of stac-pydantic pinned here is too old to include stac-utils/stac-pydantic#43. I see stac-utils/stac-pydantic#45 might be addressing the conformsTo issue.

from stac-fastapi.

geospatial-jeff avatar geospatial-jeff commented on August 23, 2024

I think this is because the landing page sets response_model_exclude_unset=True. If I make this change

This is the case. It's kind of a weird interaction in pydantic that I wasn't aware of, where a default value that is set as a constant is excluded from the model output because technically it is not set.

import pydantic


class MyModel(pydantic.BaseModel):
    const: str = pydantic.Field("stac-version", const=True)


inst = MyModel()
print(inst.json(exclude_unset=True))

>>> {}

I'd rather fix this upstream in stac-pydantic so that stac_version is returned even if the response_model_exclude_unset is set, since its definitely a field that should always be returned. I'm sure this is also a problem in Items and Collections.
Speaking of stac-pydantic, I have some time planned this week to update it to the latest version of the spec, at which point I think it makes sense to update this project to use the latest stac-pydantic version, which would contain a fix to this issue as well as the other stac-pydantic issues you mention.

from stac-fastapi.

geospatial-jeff avatar geospatial-jeff commented on August 23, 2024

This same behavior is also removing the geojson type fields from the payload for similar reasons.

from stac-fastapi.

geospatial-jeff avatar geospatial-jeff commented on August 23, 2024

This is sort of fixed now that the api defaults to not using pydantic models to validate responses which skips this behavior. Closing for now but please feel free to reopen if this comes up again.

from stac-fastapi.

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.